From 85af3ea21a5a772cb22756190268ba3f921a6400 Mon Sep 17 00:00:00 2001 From: Shinya Maeda Date: Fri, 3 Aug 2018 15:13:39 +0900 Subject: Added unique identifier to calculate_reactive_cache. Decoupled comparison logic to service. Fixed N+1 select queries. --- spec/models/ci/build_spec.rb | 2 +- spec/models/merge_request_spec.rb | 19 +++++++------------ 2 files changed, 8 insertions(+), 13 deletions(-) (limited to 'spec/models') diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index 7137c07c55d..858e448a3d8 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -2845,7 +2845,7 @@ describe Ci::Build do context 'when build does not have test reports' do it 'raises an error' do - expect { subject }.to raise_error(ArgumentError) + expect { subject }.to raise_error(NoMethodError) end end end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index 161c0b48626..d28250dbab7 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -1127,7 +1127,9 @@ describe MergeRequest do end context 'when head pipeline has test reports' do - let!(:job_artifact) { create(:ci_job_artifact, :junit, job: head_pipeline.builds.first, project: project) } + before do + create(:ci_job_artifact, :junit, job: head_pipeline.builds.first, project: project) + end context 'when reactive cache worker is parsing asynchronously' do it 'returns status' do @@ -1141,17 +1143,10 @@ describe MergeRequest do end it 'returns status and data' do - expect(subject[:status]).to eq(:parsed) - expect(subject[:data]).to be_a(String) - end + expect_any_instance_of(Ci::CompareTestReportsService) + .to receive(:execute).with(base_pipeline.iid, head_pipeline.iid) - context 'when test reports contains invalid data' do - let!(:job_artifact) { create(:ci_job_artifact, :junit_with_corrupted_data, job: head_pipeline.builds.first, project: project) } - - it 'returns status and error message' do - expect(subject[:status]).to eq(:error) - expect(subject[:status_reason]).to eq('Invalid XML data') - end + subject end end end @@ -1159,7 +1154,7 @@ describe MergeRequest do context 'when head pipeline does not have test reports' do it 'returns status and error message' do expect(subject[:status]).to eq(:error) - expect(subject[:status_reason]).to eq('head pipeline does not have test reports') + expect(subject[:status_reason]).to eq('This merge request does not have test reports') end end end -- cgit v1.2.1