diff options
Diffstat (limited to 'spec/models/deployment_spec.rb')
-rw-r--r-- | spec/models/deployment_spec.rb | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/spec/models/deployment_spec.rb b/spec/models/deployment_spec.rb index 080ff2f3f43..212fcd884a8 100644 --- a/spec/models/deployment_spec.rb +++ b/spec/models/deployment_spec.rb @@ -49,6 +49,33 @@ describe Deployment, models: true do end end + describe '#metrics' do + let(:deployment) { create(:deployment) } + + subject { deployment.metrics(1.hour) } + + context 'metrics are disabled' do + it { is_expected.to eq({}) } + end + + context 'metrics are enabled' do + let(:simple_metrics) do + { + success: true, + metrics: {}, + last_update: 42 + } + end + + before do + allow(deployment.project).to receive_message_chain(:monitoring_service, :metrics) + .with(any_args).and_return(simple_metrics) + end + + it { is_expected.to eq(simple_metrics.merge(deployment_time: deployment.created_at.utc.to_i)) } + end + end + describe '#stop_action' do let(:build) { create(:ci_build) } |