From 93780da67ceebac19033bb0c44483e3af2d38a18 Mon Sep 17 00:00:00 2001 From: Mayra Cabrera Date: Thu, 19 Apr 2018 07:20:53 +0000 Subject: Resolve "Show `failure_reason` in jobs view content section" --- spec/serializers/job_entity_spec.rb | 63 +++++++++++++++++++++++++++++++------ 1 file changed, 53 insertions(+), 10 deletions(-) (limited to 'spec/serializers') diff --git a/spec/serializers/job_entity_spec.rb b/spec/serializers/job_entity_spec.rb index 24a6f1a2a8a..c90396ebb28 100644 --- a/spec/serializers/job_entity_spec.rb +++ b/spec/serializers/job_entity_spec.rb @@ -133,22 +133,65 @@ describe JobEntity do context 'when job failed' do let(:job) { create(:ci_build, :script_failure) } - describe 'status' do - it 'should contain the failure reason inside label' do - expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip - expect(subject[:status][:label]).to eq('failed') - expect(subject[:status][:tooltip]).to eq('failed
(script failure)') - end + it 'contains details' do + expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip + end + + it 'states that it failed' do + expect(subject[:status][:label]).to eq('failed') + end + + it 'should indicate the failure reason on tooltip' do + expect(subject[:status][:tooltip]).to eq('failed
(script failure)') + end + + it 'should include a callout message with a verbose output' do + expect(subject[:callout_message]).to eq('There has been a script failure. Check the job log for more information') + end + + it 'should state that it is not recoverable' do + expect(subject[:recoverable]).to be_falsy + end + end + + context 'when job is allowed to fail' do + let(:job) { create(:ci_build, :allowed_to_fail, :script_failure) } + + it 'contains details' do + expect(subject[:status]).to include :icon, :favicon, :text, :label, :tooltip + end + + it 'states that it failed' do + expect(subject[:status][:label]).to eq('failed (allowed to fail)') + end + + it 'should indicate the failure reason on tooltip' do + expect(subject[:status][:tooltip]).to eq('failed
(script failure) (allowed to fail)') + end + + it 'should include a callout message with a verbose output' do + expect(subject[:callout_message]).to eq('There has been a script failure. Check the job log for more information') + end + + it 'should state that it is not recoverable' do + expect(subject[:recoverable]).to be_falsy + end + end + + context 'when job failed and is recoverable' do + let(:job) { create(:ci_build, :api_failure) } + + it 'should state it is recoverable' do + expect(subject[:recoverable]).to be_truthy end end context 'when job passed' do let(:job) { create(:ci_build, :success) } - describe 'status' do - it 'should not contain the failure reason inside label' do - expect(subject[:status][:label]).to eq('passed') - end + it 'should not include callout message or recoverable keys' do + expect(subject).not_to include('callout_message') + expect(subject).not_to include('recoverable') end end end -- cgit v1.2.3