diff options
-rw-r--r-- | qa/qa/specs/helpers/quarantine.rb | 18 | ||||
-rw-r--r-- | qa/spec/specs/helpers/quarantine_spec.rb | 20 | ||||
-rw-r--r-- | spec/models/container_expiration_policy_spec.rb | 3 |
3 files changed, 38 insertions, 3 deletions
diff --git a/qa/qa/specs/helpers/quarantine.rb b/qa/qa/specs/helpers/quarantine.rb index ca0ce32e74f..8b14184f3b7 100644 --- a/qa/qa/specs/helpers/quarantine.rb +++ b/qa/qa/specs/helpers/quarantine.rb @@ -43,7 +43,23 @@ module QA::Specs::Helpers # the quarantined tests when they're not run so that we're aware of them skip("Only running tests tagged with :quarantine and any of #{included_filters.keys}") if should_skip_when_focused?(example.metadata, included_filters) else - skip('In quarantine') if example.metadata.key?(:quarantine) + if example.metadata.key?(:quarantine) + quarantine_message = %w(In quarantine) + quarantine_tag = example.metadata[:quarantine] + + if !!quarantine_tag + quarantine_message << case quarantine_tag + when String + ": #{quarantine_tag}" + when Hash + ": #{quarantine_tag[:issue]}" + else + '' + end + end + + skip(quarantine_message.join(' ').strip) + end end end diff --git a/qa/spec/specs/helpers/quarantine_spec.rb b/qa/spec/specs/helpers/quarantine_spec.rb index 2538632c032..d5c6820f0a9 100644 --- a/qa/spec/specs/helpers/quarantine_spec.rb +++ b/qa/spec/specs/helpers/quarantine_spec.rb @@ -155,6 +155,26 @@ describe QA::Specs::Helpers::Quarantine do expect(group.examples.first.execution_result.status).to eq(:passed) end + + context 'quarantine message' do + shared_examples 'test with quarantine message' do |quarantine_tag| + it 'outputs the quarantine message' do + group = describe_successfully do + it('is quarantined', quarantine: quarantine_tag) {} + end + + expect(group.examples.first.execution_result.pending_message) + .to eq('In quarantine : for a reason') + end + end + + it_behaves_like 'test with quarantine message', 'for a reason' + + it_behaves_like 'test with quarantine message', { + issue: 'for a reason', + environment: [:nightly, :staging] + } + end end context 'with :quarantine focused' do diff --git a/spec/models/container_expiration_policy_spec.rb b/spec/models/container_expiration_policy_spec.rb index 15096ae8a8b..1bce4c3b20a 100644 --- a/spec/models/container_expiration_policy_spec.rb +++ b/spec/models/container_expiration_policy_spec.rb @@ -43,8 +43,7 @@ RSpec.describe ContainerExpirationPolicy, type: :model do subject { described_class.preloaded } before do - # container_expiration_policies are created for every new project - create_list(:project, 3) + create_list(:container_expiration_policy, 3) end it 'preloads the associations' do |