summaryrefslogtreecommitdiff
path: root/spec/models/member_spec.rb
diff options
context:
space:
mode:
authorJames Lopez <james@gitlab.com>2018-12-06 13:15:29 +0000
committerDouglas Barbosa Alexandre <dbalexandre@gmail.com>2018-12-06 13:15:29 +0000
commit64c11f104ceffdb7699686445ddc16c894dbe0c5 (patch)
treed4331a41db06511c3f4daaa6ec853110f31b4260 /spec/models/member_spec.rb
parent39c769aee8af82cd755a4c666a22eb5d6bec808e (diff)
downloadgitlab-ce-64c11f104ceffdb7699686445ddc16c894dbe0c5.tar.gz
Resolve "Can add an existing group member into a group project with new permissions but permissions are not overridden"
Diffstat (limited to 'spec/models/member_spec.rb')
-rw-r--r--spec/models/member_spec.rb23
1 files changed, 23 insertions, 0 deletions
diff --git a/spec/models/member_spec.rb b/spec/models/member_spec.rb
index fca1b1f90d9..188beac1582 100644
--- a/spec/models/member_spec.rb
+++ b/spec/models/member_spec.rb
@@ -53,6 +53,29 @@ describe Member do
expect(member).to be_valid
end
end
+
+ context "when a child member inherits its access level" do
+ let(:user) { create(:user) }
+ let(:member) { create(:group_member, :developer, user: user) }
+ let(:child_group) { create(:group, parent: member.group) }
+ let(:child_member) { build(:group_member, group: child_group, user: user) }
+
+ it "requires a higher level" do
+ child_member.access_level = GroupMember::REPORTER
+
+ child_member.validate
+
+ expect(child_member).not_to be_valid
+ end
+
+ it "is valid with a higher level" do
+ child_member.access_level = GroupMember::MAINTAINER
+
+ child_member.validate
+
+ expect(child_member).to be_valid
+ end
+ end
end
describe 'Scopes & finders' do