summaryrefslogtreecommitdiff
path: root/spec/workers/pipeline_metrics_worker_spec.rb
diff options
context:
space:
mode:
authorJames Lopez <james@jameslopez.es>2016-10-20 16:20:04 +0200
committerJames Lopez <james@jameslopez.es>2016-11-17 08:22:55 +0100
commitebd5ced7eb296ce10160021d8999d21b36b24da9 (patch)
tree710dc319adbcfdabb8297333d77f0626b33bcedc /spec/workers/pipeline_metrics_worker_spec.rb
parent52e2729bf44ff3376071c2462679b46e9f67a44e (diff)
downloadgitlab-ce-ebd5ced7eb296ce10160021d8999d21b36b24da9.tar.gz
Added test events specs and logic. Also fixed some SQL and refactored the pipeline worker spec.
Diffstat (limited to 'spec/workers/pipeline_metrics_worker_spec.rb')
-rw-r--r--spec/workers/pipeline_metrics_worker_spec.rb18
1 files changed, 11 insertions, 7 deletions
diff --git a/spec/workers/pipeline_metrics_worker_spec.rb b/spec/workers/pipeline_metrics_worker_spec.rb
index 2c9e7c2cd02..2d47d93acec 100644
--- a/spec/workers/pipeline_metrics_worker_spec.rb
+++ b/spec/workers/pipeline_metrics_worker_spec.rb
@@ -15,32 +15,36 @@ describe PipelineMetricsWorker do
end
describe '#perform' do
- subject { described_class.new.perform(pipeline.id) }
+ before do
+ described_class.new.perform(pipeline.id)
+ end
context 'when pipeline is running' do
let(:status) { 'running' }
it 'records the build start time' do
- subject
-
expect(merge_request.reload.metrics.latest_build_started_at).to be_like_time(pipeline.started_at)
end
it 'clears the build end time' do
- subject
-
expect(merge_request.reload.metrics.latest_build_finished_at).to be_nil
end
+
+ it 'records the pipeline' do
+ expect(merge_request.reload.metrics.pipeline).to eq(pipeline)
+ end
end
context 'when pipeline succeeded' do
let(:status) { 'success' }
it 'records the build end time' do
- subject
-
expect(merge_request.reload.metrics.latest_build_finished_at).to be_like_time(pipeline.finished_at)
end
+
+ it 'records the pipeline' do
+ expect(merge_request.reload.metrics.pipeline).to eq(pipeline)
+ end
end
end
end