summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorGilbert Roulot <groulot@gitlab.com>2018-11-05 14:45:36 +0100
committerKamil TrzciƄski <ayufan@ayufan.eu>2018-12-11 11:39:22 +0100
commite6226e8cb3d7e79500482ba2cef604133f667381 (patch)
treeacf0f3d0b822f122da9125333f210ccce477c0d0 /spec
parent85f430cb3cde4ff8c4d24c1b2a426670e38dd44f (diff)
downloadgitlab-ce-e6226e8cb3d7e79500482ba2cef604133f667381.tar.gz
Generalise test compare service
It adds a base class for CompareTestReportsService containing common code with CompareLicenseManagementReportsService which is present in GitLab Enterprise Edition.
Diffstat (limited to 'spec')
-rw-r--r--spec/lib/gitlab/ci/parsers_spec.rb (renamed from spec/lib/gitlab/ci/parsers/test_spec.rb)8
-rw-r--r--spec/models/merge_request_spec.rb24
2 files changed, 29 insertions, 3 deletions
diff --git a/spec/lib/gitlab/ci/parsers/test_spec.rb b/spec/lib/gitlab/ci/parsers_spec.rb
index 0b85b432677..4b647bffe59 100644
--- a/spec/lib/gitlab/ci/parsers/test_spec.rb
+++ b/spec/lib/gitlab/ci/parsers_spec.rb
@@ -1,6 +1,8 @@
+# frozen_string_literal: true
+
require 'spec_helper'
-describe Gitlab::Ci::Parsers::Test do
+describe Gitlab::Ci::Parsers do
describe '.fabricate!' do
subject { described_class.fabricate!(file_type) }
@@ -8,7 +10,7 @@ describe Gitlab::Ci::Parsers::Test do
let(:file_type) { 'junit' }
it 'fabricates the class' do
- is_expected.to be_a(described_class::Junit)
+ is_expected.to be_a(described_class::Test::Junit)
end
end
@@ -16,7 +18,7 @@ describe Gitlab::Ci::Parsers::Test do
let(:file_type) { 'undefined' }
it 'raises an error' do
- expect { subject }.to raise_error(Gitlab::Ci::Parsers::Test::ParserNotFoundError)
+ expect { subject }.to raise_error(Gitlab::Ci::Parsers::ParserNotFoundError)
end
end
end
diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb
index c3152d2021b..bf4117fbcaf 100644
--- a/spec/models/merge_request_spec.rb
+++ b/spec/models/merge_request_spec.rb
@@ -1339,6 +1339,30 @@ describe MergeRequest do
end
end
+ describe '#calculate_reactive_cache' do
+ let(:project) { create(:project, :repository) }
+ let(:merge_request) { create(:merge_request, source_project: project) }
+ subject { merge_request.calculate_reactive_cache(service_class_name) }
+
+ context 'when given an unknown service class name' do
+ let(:service_class_name) { 'Integer' }
+
+ it 'raises a NameError exception' do
+ expect { subject }.to raise_error(NameError, service_class_name)
+ end
+ end
+
+ context 'when given a known service class name' do
+ let(:service_class_name) { 'Ci::CompareTestReportsService' }
+
+ it 'does not raises a NameError exception' do
+ allow_any_instance_of(service_class_name.constantize).to receive(:execute).and_return(nil)
+
+ expect { subject }.not_to raise_error(NameError)
+ end
+ end
+ end
+
describe '#compare_test_reports' do
subject { merge_request.compare_test_reports }