Do not show play action if user not allowed to run it

This commit is contained in:
Grzegorz Bizon 2017-04-06 13:08:45 +02:00
parent 3dbef510c1
commit 5b6202cce1
2 changed files with 11 additions and 3 deletions

View File

@ -10,7 +10,7 @@ module Gitlab
end
def has_action?
can?(user, :update_build, subject)
can?(user, :update_build, subject) && subject.can_play?(user)
end
def action_icon

View File

@ -17,9 +17,17 @@ describe Gitlab::Ci::Status::Build::Play do
describe '#has_action?' do
context 'when user is allowed to update build' do
before { build.project.team << [user, :developer] }
context 'when user can push to branch' do
before { build.project.add_master(user) }
it { is_expected.to have_action }
it { is_expected.to have_action }
end
context 'when user can not push to the branch' do
before { build.project.add_developer(user) }
it { is_expected.not_to have_action }
end
end
context 'when user is not allowed to update build' do