summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-12-12 14:59:46 +0100
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2016-12-12 14:59:46 +0100
commitab37be2dda8188c56d6e76a23b46ccc88c42baa8 (patch)
tree7f77becde9ab423daf0020b04ae0772aaa908de3
parentf91e8269c18ac80d6f43fdd7b87362e5c9ccbc94 (diff)
downloadgitlab-ce-ab37be2dda8188c56d6e76a23b46ccc88c42baa8.tar.gz
Add specs for build stop extended detailed status
-rw-r--r--lib/gitlab/ci/status/build/stop.rb4
-rw-r--r--spec/lib/gitlab/ci/status/build/stop_spec.rb59
2 files changed, 59 insertions, 4 deletions
diff --git a/lib/gitlab/ci/status/build/stop.rb b/lib/gitlab/ci/status/build/stop.rb
index 76c66fab323..a4966a55892 100644
--- a/lib/gitlab/ci/status/build/stop.rb
+++ b/lib/gitlab/ci/status/build/stop.rb
@@ -13,10 +13,6 @@ module Gitlab
'stop'
end
- def icon
- 'icon_status_skipped'
- end
-
def has_action?
can?(user, :update_build, subject)
end
diff --git a/spec/lib/gitlab/ci/status/build/stop_spec.rb b/spec/lib/gitlab/ci/status/build/stop_spec.rb
new file mode 100644
index 00000000000..f2121210417
--- /dev/null
+++ b/spec/lib/gitlab/ci/status/build/stop_spec.rb
@@ -0,0 +1,59 @@
+require 'spec_helper'
+
+describe Gitlab::Ci::Status::Build::Stop do
+ let(:core_status) { double('core status') }
+ let(:user) { double('user') }
+
+ subject do
+ described_class.new(core_status)
+ end
+
+ describe '#text' do
+ it { expect(subject.text).to eq 'stop' }
+ end
+
+ describe '#label' do
+ it { expect(subject.label).to eq 'stop' }
+ end
+
+ describe '#icon' do
+ it 'does not override core status icon' do
+ expect(core_status).to receive(:icon)
+
+ subject.icon
+ end
+ end
+
+ describe '.matches?' do
+ context 'build is playable' do
+ context 'when build stops an environment' do
+ let(:build) do
+ create(:ci_build, :playable, :teardown_environment)
+ end
+
+ it 'is a correct match' do
+ expect(described_class.matches?(build, user))
+ .to be true
+ end
+ end
+
+ context 'when build does not stop an environment' do
+ let(:build) { create(:ci_build, :playable) }
+
+ it 'does not match' do
+ expect(described_class.matches?(build, user))
+ .to be false
+ end
+ end
+ end
+
+ context 'when build is not playable' do
+ let(:build) { create(:ci_build) }
+
+ it 'does not match' do
+ expect(described_class.matches?(build, user))
+ .to be false
+ end
+ end
+ end
+end