From f379e1b370d033097c1d0102401eb6156384890c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Matija=20=C4=8Cupi=C4=87?= Date: Thu, 5 Apr 2018 13:52:54 +0200 Subject: Rename success to erased empty state spec --- lib/gitlab/ci/status/build/erased.rb | 21 +++++++++++++++ lib/gitlab/ci/status/build/factory.rb | 2 +- lib/gitlab/ci/status/build/success.rb | 21 --------------- spec/lib/gitlab/ci/status/build/erased_spec.rb | 33 +++++++++++++++++++++++ spec/lib/gitlab/ci/status/build/factory_spec.rb | 35 ++++++++++++++++--------- spec/lib/gitlab/ci/status/build/success_spec.rb | 35 ------------------------- 6 files changed, 78 insertions(+), 69 deletions(-) create mode 100644 lib/gitlab/ci/status/build/erased.rb delete mode 100644 lib/gitlab/ci/status/build/success.rb create mode 100644 spec/lib/gitlab/ci/status/build/erased_spec.rb delete mode 100644 spec/lib/gitlab/ci/status/build/success_spec.rb diff --git a/lib/gitlab/ci/status/build/erased.rb b/lib/gitlab/ci/status/build/erased.rb new file mode 100644 index 00000000000..3a5113b16b6 --- /dev/null +++ b/lib/gitlab/ci/status/build/erased.rb @@ -0,0 +1,21 @@ +module Gitlab + module Ci + module Status + module Build + class Erased < Status::Extended + def illustration + { + image: 'illustrations/skipped-job_empty.svg', + size: 'svg-430', + title: _('Job has been erased') + } + end + + def self.matches?(build, user) + build.erased? + end + end + end + end + end +end diff --git a/lib/gitlab/ci/status/build/factory.rb b/lib/gitlab/ci/status/build/factory.rb index d3a34384f6f..466a0a989ad 100644 --- a/lib/gitlab/ci/status/build/factory.rb +++ b/lib/gitlab/ci/status/build/factory.rb @@ -9,7 +9,7 @@ module Gitlab Status::Build::Created, Status::Build::Pending, Status::Build::Skipped, - Status::Build::Success], + Status::Build::Erased], [Status::Build::Cancelable, Status::Build::Retryable], [Status::Build::FailedAllowed, diff --git a/lib/gitlab/ci/status/build/success.rb b/lib/gitlab/ci/status/build/success.rb deleted file mode 100644 index daf43315c90..00000000000 --- a/lib/gitlab/ci/status/build/success.rb +++ /dev/null @@ -1,21 +0,0 @@ -module Gitlab - module Ci - module Status - module Build - class Success < Status::Extended - def illustration - { - image: 'illustrations/skipped-job_empty.svg', - size: 'svg-430', - title: _('Job has been erased') - } - end - - def self.matches?(build, user) - !build.has_trace? && build.success? - end - end - end - end - end -end diff --git a/spec/lib/gitlab/ci/status/build/erased_spec.rb b/spec/lib/gitlab/ci/status/build/erased_spec.rb new file mode 100644 index 00000000000..0acd271e375 --- /dev/null +++ b/spec/lib/gitlab/ci/status/build/erased_spec.rb @@ -0,0 +1,33 @@ +require 'spec_helper' + +describe Gitlab::Ci::Status::Build::Erased do + let(:user) { create(:user) } + + subject do + described_class.new(double('subject')) + end + + describe '#illustration' do + it { expect(subject.illustration).to include(:image, :size, :title) } + end + + describe '.matches?' do + subject { described_class.matches?(build, user) } + + context 'when build is erased' do + let(:build) { create(:ci_build, :success, :erased) } + + it 'is a correct match' do + expect(subject).to be true + end + end + + context 'when build is not erased' do + let(:build) { create(:ci_build, :success, :trace_artifact) } + + it 'does not match' do + expect(subject).to be false + end + end + end +end diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb index d68d8f6f105..94eedc50bb2 100644 --- a/spec/lib/gitlab/ci/status/build/factory_spec.rb +++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb @@ -36,21 +36,32 @@ describe Gitlab::Ci::Status::Build::Factory do expect(status).to have_details expect(status).to have_action end + end - context 'when job log gets erased' do - before do - build.erase - end + context 'when build is erased' do + let(:build) { create(:ci_build, :success, :erased) } - it 'matches correct extended statuses' do - expect(factory.extended_statuses) - .to eq [Gitlab::Ci::Status::Build::Success, - Gitlab::Ci::Status::Build::Retryable] - end + it 'matches correct core status' do + expect(factory.core_status).to be_a Gitlab::Ci::Status::Success + end - it 'fabricates a retryable build status' do - expect(status).to be_a Gitlab::Ci::Status::Build::Retryable - end + it 'matches correct extended statuses' do + expect(factory.extended_statuses) + .to eq [Gitlab::Ci::Status::Build::Erased, + Gitlab::Ci::Status::Build::Retryable] + end + + it 'fabricates a retryable build status' do + expect(status).to be_a Gitlab::Ci::Status::Build::Retryable + end + + it 'fabricates status with correct details' do + expect(status.text).to eq 'passed' + expect(status.icon).to eq 'status_success' + expect(status.favicon).to eq 'favicon_status_success' + expect(status.label).to eq 'passed' + expect(status).to have_details + expect(status).to have_action end end diff --git a/spec/lib/gitlab/ci/status/build/success_spec.rb b/spec/lib/gitlab/ci/status/build/success_spec.rb deleted file mode 100644 index e67ab461463..00000000000 --- a/spec/lib/gitlab/ci/status/build/success_spec.rb +++ /dev/null @@ -1,35 +0,0 @@ -require 'spec_helper' - -describe Gitlab::Ci::Status::Build::Success do - let(:user) { create(:user) } - - subject do - described_class.new(double('subject')) - end - - describe '#illustration' do - it { expect(subject.illustration).to include(:image, :size, :title) } - end - - describe '.matches?' do - subject { described_class.matches?(build, user) } - - context 'when build succeeded but does not have trace' do - let(:build) { create(:ci_build, :success) } - - it 'is a correct match' do - build.erase - - expect(subject).to be true - end - end - - context 'when build succeed but has trace' do - let!(:build) { create(:ci_build, :success, :trace_artifact) } - - it 'does not match' do - expect(subject).to be false - end - end - end -end -- cgit v1.2.1