summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-01 14:29:20 +0200
committerGrzegorz Bizon <grzesiek.bizon@gmail.com>2017-05-01 14:29:20 +0200
commit4f2cc5951f3d2862a44fe124ef9a879162028e62 (patch)
treea69c7bf5ce036ea8222d2b17ab14366702290a25
parent6baaa8a98e10ff93ba3f481052bb68fdafb6e2c1 (diff)
downloadgitlab-ce-4f2cc5951f3d2862a44fe124ef9a879162028e62.tar.gz
Extend action tooltop to show info about abilities
-rw-r--r--lib/gitlab/ci/status/build/play.rb6
-rw-r--r--spec/lib/gitlab/ci/status/build/factory_spec.rb2
-rw-r--r--spec/lib/gitlab/ci/status/build/play_spec.rb65
3 files changed, 42 insertions, 31 deletions
diff --git a/lib/gitlab/ci/status/build/play.rb b/lib/gitlab/ci/status/build/play.rb
index 4c893f62925..8130c7d1c90 100644
--- a/lib/gitlab/ci/status/build/play.rb
+++ b/lib/gitlab/ci/status/build/play.rb
@@ -6,7 +6,11 @@ module Gitlab
include Status::Extended
def label
- 'manual play action'
+ if has_action?
+ 'manual play action'
+ else
+ 'manual play action (not allowed)'
+ end
end
def has_action?
diff --git a/spec/lib/gitlab/ci/status/build/factory_spec.rb b/spec/lib/gitlab/ci/status/build/factory_spec.rb
index 2ab67127b1e..2de00c28945 100644
--- a/spec/lib/gitlab/ci/status/build/factory_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/factory_spec.rb
@@ -216,7 +216,7 @@ describe Gitlab::Ci::Status::Build::Factory do
expect(status.group).to eq 'manual'
expect(status.icon).to eq 'icon_status_manual'
expect(status.favicon).to eq 'favicon_status_manual'
- expect(status.label).to eq 'manual play action'
+ expect(status.label).to include 'manual play action'
expect(status).to have_details
expect(status.action_path).to include 'play'
end
diff --git a/spec/lib/gitlab/ci/status/build/play_spec.rb b/spec/lib/gitlab/ci/status/build/play_spec.rb
index 95f1388a9b9..abefdbe7c66 100644
--- a/spec/lib/gitlab/ci/status/build/play_spec.rb
+++ b/spec/lib/gitlab/ci/status/build/play_spec.rb
@@ -1,51 +1,58 @@
require 'spec_helper'
describe Gitlab::Ci::Status::Build::Play do
- let(:status) { double('core') }
- let(:user) { double('user') }
+ let(:user) { create(:user) }
+ let(:build) { create(:ci_build, :manual) }
+ let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
subject { described_class.new(status) }
- describe '#label' do
- it { expect(subject.label).to eq 'manual play action' }
- end
-
- describe 'action details' do
- let(:user) { create(:user) }
- let(:build) { create(:ci_build, :manual) }
- let(:status) { Gitlab::Ci::Status::Core.new(build, user) }
+ context 'when user is allowed to update build' do
+ context 'when user can push to branch' do
+ before { build.project.add_master(user) }
- describe '#has_action?' do
- context 'when user is allowed to update build' do
- context 'when user can push to branch' do
- before { build.project.add_master(user) }
+ describe '#has_action?' do
+ it { is_expected.to have_action }
+ end
- it { is_expected.to have_action }
+ describe '#label' do
+ it 'has a label that says it is a manual action' do
+ expect(subject.label).to eq 'manual play action'
end
+ end
+ end
- context 'when user can not push to the branch' do
- before { build.project.add_developer(user) }
+ context 'when user can not push to the branch' do
+ before { build.project.add_developer(user) }
- it { is_expected.not_to have_action }
- end
+ describe 'has_action?' do
+ it { is_expected.not_to have_action }
end
- context 'when user is not allowed to update build' do
- it { is_expected.not_to have_action }
+ describe '#label' do
+ it 'has a label that says user is not allowed to play it' do
+ expect(subject.label).to eq 'manual play action (not allowed)'
+ end
end
end
+ end
- describe '#action_path' do
- it { expect(subject.action_path).to include "#{build.id}/play" }
+ context 'when user is not allowed to update build' do
+ describe '#has_action?' do
+ it { is_expected.not_to have_action }
end
+ end
- describe '#action_icon' do
- it { expect(subject.action_icon).to eq 'icon_action_play' }
- end
+ describe '#action_path' do
+ it { expect(subject.action_path).to include "#{build.id}/play" }
+ end
- describe '#action_title' do
- it { expect(subject.action_title).to eq 'Play' }
- end
+ describe '#action_icon' do
+ it { expect(subject.action_icon).to eq 'icon_action_play' }
+ end
+
+ describe '#action_title' do
+ it { expect(subject.action_title).to eq 'Play' }
end
describe '.matches?' do