summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatija Čupić <matteeyah@gmail.com>2018-02-02 03:39:07 +0100
committerMatija Čupić <matteeyah@gmail.com>2018-02-02 03:39:07 +0100
commit8f942a0534384f73cfa8686a0c67ec6451c5c39b (patch)
tree6c94bdb247aa11896e9a47fc6e7476a10949a146
parentad38e120069748049786373af1c2286cf9c849eb (diff)
downloadgitlab-ce-8f942a0534384f73cfa8686a0c67ec6451c5c39b.tar.gz
Use policies instead of role checks in ClustersHelper
-rw-r--r--app/helpers/callouts_helper.rb3
-rw-r--r--spec/helpers/callouts_helper_spec.rb24
2 files changed, 9 insertions, 18 deletions
diff --git a/app/helpers/callouts_helper.rb b/app/helpers/callouts_helper.rb
index 3841d288f52..168b731ae89 100644
--- a/app/helpers/callouts_helper.rb
+++ b/app/helpers/callouts_helper.rb
@@ -8,8 +8,7 @@ module CalloutsHelper
def show_gke_cluster_integration_callout?(project)
current_user && !user_dismissed?(GKE_CLUSTER_INTEGRATION) &&
- (project.team.master?(current_user) ||
- current_user == project.owner)
+ can?(current_user, :create_cluster, project)
end
private
diff --git a/spec/helpers/callouts_helper_spec.rb b/spec/helpers/callouts_helper_spec.rb
index 7ec8ca8eb0c..d0a5addc231 100644
--- a/spec/helpers/callouts_helper_spec.rb
+++ b/spec/helpers/callouts_helper_spec.rb
@@ -17,30 +17,22 @@ describe CalloutsHelper do
allow(helper).to receive(:user_dismissed?).and_return(false)
end
- context 'when user is master' do
+ context 'when user can create a cluster' do
before do
- allow(project).to receive_message_chain(:team, :master?).and_return(true)
+ allow(helper).to receive(:can?).with(anything, :create_cluster, anything)
+ .and_return(true)
end
it { is_expected.to be true }
end
- context 'when user is not master' do
- context 'when the user is owner' do
- before do
- allow(project).to receive(:owner).and_return(user)
- end
-
- it { is_expected.to be true }
+ context 'when user can not create a cluster' do
+ before do
+ allow(helper).to receive(:can?).with(anything, :create_cluster, anything)
+ .and_return(false)
end
- context 'when the user is not owner' do
- before do
- allow(project).to receive_message_chain(:team, :master?).and_return(false)
- end
-
- it { is_expected.to be false }
- end
+ it { is_expected.to be false }
end
end