diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-29 03:09:05 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-06-29 03:09:05 +0300 |
commit | 72278d5e10d7470b59b81c1e51379baa3a6cdab8 (patch) | |
tree | f8d5198f16b06e280446a72c197969761ddef80a /spec/helpers | |
parent | 680fd17700f55b3718e4d1de56631b4a8f9e6d6c (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/projects_helper_spec.rb | 49 |
1 files changed, 49 insertions, 0 deletions
diff --git a/spec/helpers/projects_helper_spec.rb b/spec/helpers/projects_helper_spec.rb index 07479d4e1e0..20f389681b2 100644 --- a/spec/helpers/projects_helper_spec.rb +++ b/spec/helpers/projects_helper_spec.rb @@ -1565,4 +1565,53 @@ RSpec.describe ProjectsHelper, feature_category: :source_code_management do it { is_expected.to be_falsey } end end + + describe '#can_admin_associated_clusters?(project)' do + using RSpec::Parameterized::TableSyntax + + where(:project_clusters_exist, :user_can_admin_project_clusters, :group_clusters_exist, :user_can_admin_group_clusters, :expected) do + false | false | false | false | false + true | false | false | false | false + false | true | false | false | false + false | false | true | false | false + false | false | false | true | false + true | true | false | false | true + false | false | true | true | true + true | true | true | true | true + end + + with_them do + subject { helper.can_admin_associated_clusters?(project) } + + let(:clusters) { [double('Cluster')] } + let(:group) { double('Group') } + + before do + allow(project) + .to receive(:clusters) + .and_return(project_clusters_exist ? clusters : []) + allow(helper) + .to receive(:can?).with(user, :admin_cluster, project) + .and_return(user_can_admin_project_clusters) + + allow(project) + .to receive(:group) + .and_return(group) + allow(group) + .to receive(:clusters) + .and_return(group_clusters_exist ? clusters : []) + allow(helper) + .to receive(:can?).with(user, :admin_cluster, project.group) + .and_return(user_can_admin_group_clusters) + end + + it { is_expected.to eq(expected) } + end + end + + describe '#branch_rules_path' do + subject { helper.branch_rules_path } + + it { is_expected.to eq(project_settings_repository_path(project, anchor: 'js-branch-rules')) } + end end |