diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-19 21:08:39 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-06-19 21:08:39 +0300 |
commit | ce493944f48fb2ad08a5381a7ed1f37ced637bd1 (patch) | |
tree | 565c5c3bf18ce60fd6442d7581fc1af7ba148dd1 /spec/serializers/test_suite_entity_spec.rb | |
parent | e9ea5bbdf998d0bafe14cfd3d70fa545d8ebed83 (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/serializers/test_suite_entity_spec.rb')
-rw-r--r-- | spec/serializers/test_suite_entity_spec.rb | 56 |
1 files changed, 33 insertions, 23 deletions
diff --git a/spec/serializers/test_suite_entity_spec.rb b/spec/serializers/test_suite_entity_spec.rb index bd88d235013..83d3086ea6b 100644 --- a/spec/serializers/test_suite_entity_spec.rb +++ b/spec/serializers/test_suite_entity_spec.rb @@ -2,36 +2,46 @@ require 'spec_helper' -describe TestSuiteEntity do - let(:pipeline) { create(:ci_pipeline, :with_test_reports) } +RSpec.describe TestSuiteEntity do + let(:pipeline) { create(:ci_pipeline, :with_test_reports) } let(:test_suite) { pipeline.test_reports.test_suites.each_value.first } - let(:entity) { described_class.new(test_suite) } + let(:user) { create(:user) } + let(:request) { double('request', current_user: user) } - describe '#as_json' do - subject(:as_json) { entity.as_json } + subject { described_class.new(test_suite, request: request).as_json } + + context 'when details option is not present' do + it 'does not expose suite error and test cases', :aggregate_failures do + expect(subject).not_to include(:test_cases) + expect(subject).not_to include(:suite_error) + end + end + + context 'when details option is present' do + subject { described_class.new(test_suite, request: request, details: true).as_json } it 'contains the suite name' do - expect(as_json[:name]).to be_present + expect(subject[:name]).to be_present end it 'contains the total time' do - expect(as_json[:total_time]).to be_present + expect(subject[:total_time]).to be_present end it 'contains the counts' do - expect(as_json[:total_count]).to eq(4) - expect(as_json[:success_count]).to eq(2) - expect(as_json[:failed_count]).to eq(2) - expect(as_json[:skipped_count]).to eq(0) - expect(as_json[:error_count]).to eq(0) + expect(subject[:total_count]).to eq(4) + expect(subject[:success_count]).to eq(2) + expect(subject[:failed_count]).to eq(2) + expect(subject[:skipped_count]).to eq(0) + expect(subject[:error_count]).to eq(0) end it 'contains the test cases' do - expect(as_json[:test_cases].count).to eq(4) + expect(subject[:test_cases].count).to eq(4) end it 'contains an empty error message' do - expect(as_json[:suite_error]).to be_nil + expect(subject[:suite_error]).to be_nil end context 'with a suite error' do @@ -40,27 +50,27 @@ describe TestSuiteEntity do end it 'contains the suite name' do - expect(as_json[:name]).to be_present + expect(subject[:name]).to be_present end it 'contains the total time' do - expect(as_json[:total_time]).to be_present + expect(subject[:total_time]).to be_present end it 'returns all the counts as 0' do - expect(as_json[:total_count]).to eq(0) - expect(as_json[:success_count]).to eq(0) - expect(as_json[:failed_count]).to eq(0) - expect(as_json[:skipped_count]).to eq(0) - expect(as_json[:error_count]).to eq(0) + expect(subject[:total_count]).to eq(0) + expect(subject[:success_count]).to eq(0) + expect(subject[:failed_count]).to eq(0) + expect(subject[:skipped_count]).to eq(0) + expect(subject[:error_count]).to eq(0) end it 'returns no test cases' do - expect(as_json[:test_cases]).to be_empty + expect(subject[:test_cases]).to be_empty end it 'returns a suite error' do - expect(as_json[:suite_error]).to eq('a really bad error') + expect(subject[:suite_error]).to eq('a really bad error') end end end |