diff options
Diffstat (limited to 'spec/policies/group_policy_spec.rb')
-rw-r--r-- | spec/policies/group_policy_spec.rb | 96 |
1 files changed, 48 insertions, 48 deletions
diff --git a/spec/policies/group_policy_spec.rb b/spec/policies/group_policy_spec.rb index af6d6f084a9..cb49ed61efc 100644 --- a/spec/policies/group_policy_spec.rb +++ b/spec/policies/group_policy_spec.rb @@ -1,4 +1,4 @@ -require 'spec_helper' +require "spec_helper" describe GroupPolicy do let(:guest) { create(:user) } @@ -12,7 +12,7 @@ describe GroupPolicy do let(:guest_permissions) do [:read_label, :read_group, :upload_file, :read_namespace, :read_group_activity, :read_group_issues, :read_group_boards, :read_group_labels, :read_group_milestones, - :read_group_merge_requests] + :read_group_merge_requests,] end let(:reporter_permissions) { [:admin_label] } @@ -26,7 +26,7 @@ describe GroupPolicy do :create_cluster, :update_cluster, :admin_cluster, - :add_cluster + :add_cluster, ] end @@ -37,7 +37,7 @@ describe GroupPolicy do :admin_group_member, :change_visibility_level, :set_note_created_at, - (Gitlab::Database.postgresql? ? :create_subgroup : nil) + (Gitlab::Database.postgresql? ? :create_subgroup : nil), ].compact end @@ -59,7 +59,7 @@ describe GroupPolicy do permissions.each { |p| is_expected.not_to be_allowed(p) } end - context 'with no user' do + context "with no user" do let(:group) { create(:group, :public) } let(:current_user) { nil } @@ -74,7 +74,7 @@ describe GroupPolicy do end end - context 'has projects' do + context "has projects" do let(:current_user) { create(:user) } let(:project) { create(:project, namespace: group) } @@ -86,7 +86,7 @@ describe GroupPolicy do expect_allowed(:read_group, :read_list, :read_label) end - context 'in subgroups', :nested_groups do + context "in subgroups", :nested_groups do let(:subgroup) { create(:group, :private, parent: group) } let(:project) { create(:project, namespace: subgroup) } @@ -96,7 +96,7 @@ describe GroupPolicy do end end - context 'guests' do + context "guests" do let(:current_user) { guest } it do @@ -108,7 +108,7 @@ describe GroupPolicy do end end - context 'reporter' do + context "reporter" do let(:current_user) { reporter } it do @@ -120,7 +120,7 @@ describe GroupPolicy do end end - context 'developer' do + context "developer" do let(:current_user) { developer } it do @@ -132,7 +132,7 @@ describe GroupPolicy do end end - context 'maintainer' do + context "maintainer" do let(:current_user) { maintainer } it do @@ -144,7 +144,7 @@ describe GroupPolicy do end end - context 'owner' do + context "owner" do let(:current_user) { owner } it do @@ -158,7 +158,7 @@ describe GroupPolicy do end end - context 'admin' do + context "admin" do let(:current_user) { admin } it do @@ -172,15 +172,15 @@ describe GroupPolicy do end end - describe 'when nested group support feature is disabled' do + describe "when nested group support feature is disabled" do before do allow(Group).to receive(:supports_nested_objects?).and_return(false) end - context 'admin' do + context "admin" do let(:current_user) { admin } - it 'allows every owner permission except creating subgroups' do + it "allows every owner permission except creating subgroups" do create_subgroup_permission = [:create_subgroup] updated_owner_permissions = owner_permissions - create_subgroup_permission @@ -189,10 +189,10 @@ describe GroupPolicy do end end - context 'owner' do + context "owner" do let(:current_user) { owner } - it 'allows every owner permission except creating subgroups' do + it "allows every owner permission except creating subgroups" do create_subgroup_permission = [:create_subgroup] updated_owner_permissions = owner_permissions - create_subgroup_permission @@ -202,7 +202,7 @@ describe GroupPolicy do end end - describe 'private nested group use the highest access level from the group and inherited permissions', :nested_groups do + describe "private nested group use the highest access level from the group and inherited permissions", :nested_groups do let(:nested_group) { create(:group, :private, parent: group) } before do @@ -219,7 +219,7 @@ describe GroupPolicy do subject { described_class.new(current_user, nested_group) } - context 'with no user' do + context "with no user" do let(:current_user) { nil } it do @@ -231,7 +231,7 @@ describe GroupPolicy do end end - context 'guests' do + context "guests" do let(:current_user) { guest } it do @@ -243,7 +243,7 @@ describe GroupPolicy do end end - context 'reporter' do + context "reporter" do let(:current_user) { reporter } it do @@ -255,7 +255,7 @@ describe GroupPolicy do end end - context 'developer' do + context "developer" do let(:current_user) { developer } it do @@ -267,7 +267,7 @@ describe GroupPolicy do end end - context 'maintainer' do + context "maintainer" do let(:current_user) { maintainer } it do @@ -279,7 +279,7 @@ describe GroupPolicy do end end - context 'owner' do + context "owner" do let(:current_user) { owner } it do @@ -294,26 +294,26 @@ describe GroupPolicy do end end - describe 'change_share_with_group_lock' do - context 'when the current_user owns the group' do + describe "change_share_with_group_lock" do + context "when the current_user owns the group" do let(:current_user) { owner } - context 'when the group share_with_group_lock is enabled' do + context "when the group share_with_group_lock is enabled" do let(:group) { create(:group, share_with_group_lock: true, parent: parent) } - context 'when the parent group share_with_group_lock is enabled' do - context 'when the group has a grandparent' do + context "when the parent group share_with_group_lock is enabled" do + context "when the group has a grandparent" do let(:parent) { create(:group, share_with_group_lock: true, parent: grandparent) } - context 'when the grandparent share_with_group_lock is enabled' do + context "when the grandparent share_with_group_lock is enabled" do let(:grandparent) { create(:group, share_with_group_lock: true) } - context 'when the current_user owns the parent' do + context "when the current_user owns the parent" do before do parent.add_owner(current_user) end - context 'when the current_user owns the grandparent' do + context "when the current_user owns the grandparent" do before do grandparent.add_owner(current_user) end @@ -321,20 +321,20 @@ describe GroupPolicy do it { expect_allowed(:change_share_with_group_lock) } end - context 'when the current_user does not own the grandparent' do + context "when the current_user does not own the grandparent" do it { expect_disallowed(:change_share_with_group_lock) } end end - context 'when the current_user does not own the parent' do + context "when the current_user does not own the parent" do it { expect_disallowed(:change_share_with_group_lock) } end end - context 'when the grandparent share_with_group_lock is disabled' do + context "when the grandparent share_with_group_lock is disabled" do let(:grandparent) { create(:group) } - context 'when the current_user owns the parent' do + context "when the current_user owns the parent" do before do parent.add_owner(current_user) end @@ -342,16 +342,16 @@ describe GroupPolicy do it { expect_allowed(:change_share_with_group_lock) } end - context 'when the current_user does not own the parent' do + context "when the current_user does not own the parent" do it { expect_disallowed(:change_share_with_group_lock) } end end end - context 'when the group does not have a grandparent' do + context "when the group does not have a grandparent" do let(:parent) { create(:group, share_with_group_lock: true) } - context 'when the current_user owns the parent' do + context "when the current_user owns the parent" do before do parent.add_owner(current_user) end @@ -359,38 +359,38 @@ describe GroupPolicy do it { expect_allowed(:change_share_with_group_lock) } end - context 'when the current_user does not own the parent' do + context "when the current_user does not own the parent" do it { expect_disallowed(:change_share_with_group_lock) } end end end - context 'when the parent group share_with_group_lock is disabled' do + context "when the parent group share_with_group_lock is disabled" do let(:parent) { create(:group) } it { expect_allowed(:change_share_with_group_lock) } end end - context 'when the group share_with_group_lock is disabled' do + context "when the group share_with_group_lock is disabled" do it { expect_allowed(:change_share_with_group_lock) } end end - context 'when the current_user does not own the group' do + context "when the current_user does not own the group" do let(:current_user) { create(:user) } it { expect_disallowed(:change_share_with_group_lock) } end end - it_behaves_like 'clusterable policies' do + it_behaves_like "clusterable policies" do let(:clusterable) { create(:group) } let(:cluster) do create(:cluster, - :provided_by_gcp, - :group, - groups: [clusterable]) + :provided_by_gcp, + :group, + groups: [clusterable]) end end end |