summaryrefslogtreecommitdiff
path: root/spec/presenters/ci/build_presenter_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/presenters/ci/build_presenter_spec.rb')
-rw-r--r--spec/presenters/ci/build_presenter_spec.rb93
1 files changed, 88 insertions, 5 deletions
diff --git a/spec/presenters/ci/build_presenter_spec.rb b/spec/presenters/ci/build_presenter_spec.rb
index 1a8001be6ab..cc16d0f156b 100644
--- a/spec/presenters/ci/build_presenter_spec.rb
+++ b/spec/presenters/ci/build_presenter_spec.rb
@@ -72,13 +72,44 @@ describe Ci::BuildPresenter do
end
end
- context 'when build is not auto-canceled' do
- before do
- expect(build).to receive(:auto_canceled?).and_return(false)
+ context 'when build failed' do
+ let(:build) { create(:ci_build, :failed, pipeline: pipeline) }
+
+ it 'returns the reason of failure' do
+ status_title = presenter.status_title
+
+ expect(status_title).to eq('Failed <br> (unknown failure)')
end
+ end
+
+ context 'when build has failed && retried' do
+ let(:build) { create(:ci_build, :failed, :retried, pipeline: pipeline) }
- it 'does not have a status title' do
- expect(presenter.status_title).to be_nil
+ it 'does not include retried title' do
+ status_title = presenter.status_title
+
+ expect(status_title).not_to include('(retried)')
+ expect(status_title).to eq('Failed <br> (unknown failure)')
+ end
+ end
+
+ context 'when build has failed and is allowed to' do
+ let(:build) { create(:ci_build, :failed, :allowed_to_fail, pipeline: pipeline) }
+
+ it 'returns the reason of failure' do
+ status_title = presenter.status_title
+
+ expect(status_title).to eq('Failed <br> (unknown failure)')
+ end
+ end
+
+ context 'For any other build' do
+ let(:build) { create(:ci_build, :success, pipeline: pipeline) }
+
+ it 'returns the status' do
+ tooltip_description = presenter.status_title
+
+ expect(tooltip_description).to eq('Success')
end
end
end
@@ -134,4 +165,56 @@ describe Ci::BuildPresenter do
end
end
end
+
+ describe '#tooltip_message' do
+ context 'When build has failed' do
+ let(:build) { create(:ci_build, :script_failure, pipeline: pipeline) }
+
+ it 'returns the reason of failure' do
+ tooltip = subject.tooltip_message
+
+ expect(tooltip).to eq("#{build.name} - failed <br> (script failure)")
+ end
+ end
+
+ context 'When build has failed and retried' do
+ let(:build) { create(:ci_build, :script_failure, :retried, pipeline: pipeline) }
+
+ it 'should include the reason of failure and the retried title' do
+ tooltip = subject.tooltip_message
+
+ expect(tooltip).to eq("#{build.name} - failed <br> (script failure) (retried)")
+ end
+ end
+
+ context 'When build has failed and is allowed to' do
+ let(:build) { create(:ci_build, :script_failure, :allowed_to_fail, pipeline: pipeline) }
+
+ it 'should include the reason of failure' do
+ tooltip = subject.tooltip_message
+
+ expect(tooltip).to eq("#{build.name} - failed <br> (script failure) (allowed to fail)")
+ end
+ end
+
+ context 'For any other build (no retried)' do
+ let(:build) { create(:ci_build, :success, pipeline: pipeline) }
+
+ it 'should include build name and status' do
+ tooltip = subject.tooltip_message
+
+ expect(tooltip).to eq("#{build.name} - passed")
+ end
+ end
+
+ context 'For any other build (retried)' do
+ let(:build) { create(:ci_build, :success, :retried, pipeline: pipeline) }
+
+ it 'should include build name and status' do
+ tooltip = subject.tooltip_message
+
+ expect(tooltip).to eq("#{build.name} - passed (retried)")
+ end
+ end
+ end
end