summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-05 15:31:00 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-05 15:31:00 +0200
commite5f24c5490294a4e990103da24e9861f21d7bfd9 (patch)
tree2d6cf541a95f72f5e671e0b3e4e6a7881b53dac6
parent55cec2177cd97a5c0939ab34b01aa408de887d1a (diff)
downloadgitlab-ce-e5f24c5490294a4e990103da24e9861f21d7bfd9.tar.gz
Add specs for extended status for manual actions
-rw-r--r--spec/lib/gitlab/ci/status/build/action_spec.rb56
1 files changed, 56 insertions, 0 deletions
diff --git a/spec/lib/gitlab/ci/status/build/action_spec.rb b/spec/lib/gitlab/ci/status/build/action_spec.rb
new file mode 100644
index 00000000000..8c25f72804b
--- /dev/null
+++ b/spec/lib/gitlab/ci/status/build/action_spec.rb
@@ -0,0 +1,56 @@
+require 'spec_helper'
+
+describe Gitlab::Ci::Status::Build::Action do
+ let(:status) { double('core status') }
+ let(:user) { double('user') }
+
+ subject do
+ described_class.new(status)
+ end
+
+ describe '#label' do
+ before do
+ allow(status).to receive(:label).and_return('label')
+ end
+
+ context 'when status has action' do
+ before do
+ allow(status).to receive(:has_action?).and_return(true)
+ end
+
+ it 'does not append text' do
+ expect(subject.label).to eq 'label'
+ end
+ end
+
+ context 'when status does not have action' do
+ before do
+ allow(status).to receive(:has_action?).and_return(false)
+ end
+
+ it 'appends text about action not allowed' do
+ expect(subject.label).to eq 'label (not allowed)'
+ end
+ end
+ end
+
+ describe '.matches?' do
+ subject { described_class.matches?(build, user) }
+
+ context 'when build is an action' do
+ let(:build) { create(:ci_build, :manual) }
+
+ it 'is a correct match' do
+ expect(subject).to be true
+ end
+ end
+
+ context 'when build is not manual' do
+ let(:build) { create(:ci_build) }
+
+ it 'does not match' do
+ expect(subject).to be false
+ end
+ end
+ end
+end