summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/group.rb18
-rw-r--r--features/steps/admin/groups.rb2
-rw-r--r--features/steps/admin/users.rb2
-rw-r--r--features/steps/explore/groups.rb2
-rw-r--r--features/steps/invites.rb2
-rw-r--r--spec/finders/projects_finder_spec.rb2
-rw-r--r--spec/lib/gitlab/markdown/user_reference_filter_spec.rb2
-rw-r--r--spec/models/hooks/system_hook_spec.rb4
-rw-r--r--spec/models/project_team_spec.rb6
-rw-r--r--spec/requests/api/groups_spec.rb2
-rw-r--r--spec/support/markdown_feature.rb2
11 files changed, 30 insertions, 14 deletions
diff --git a/app/models/group.rb b/app/models/group.rb
index cfb8faa1491..4ff610f8e9d 100644
--- a/app/models/group.rb
+++ b/app/models/group.rb
@@ -76,8 +76,24 @@ class Group < Namespace
add_users([user], access_level, current_user)
end
+ def add_guest(user, current_user = nil)
+ add_user(user, Gitlab::Access::GUEST, current_user)
+ end
+
+ def add_reporter(user, current_user = nil)
+ add_user(user, Gitlab::Access::REPORTER, current_user)
+ end
+
+ def add_developer(user, current_user = nil)
+ add_user(user, Gitlab::Access::DEVELOPER, current_user)
+ end
+
+ def add_master(user, current_user = nil)
+ add_user(user, Gitlab::Access::MASTER, current_user)
+ end
+
def add_owner(user, current_user = nil)
- self.add_user(user, Gitlab::Access::OWNER, current_user)
+ add_user(user, Gitlab::Access::OWNER, current_user)
end
def has_owner?(user)
diff --git a/features/steps/admin/groups.rb b/features/steps/admin/groups.rb
index 9cc74a97c3a..83a3f48abe3 100644
--- a/features/steps/admin/groups.rb
+++ b/features/steps/admin/groups.rb
@@ -58,7 +58,7 @@ class Spinach::Features::AdminGroups < Spinach::FeatureSteps
end
step 'we have user "John Doe" in group' do
- current_group.add_user(user_john, Gitlab::Access::REPORTER)
+ current_group.add_reporter(user_john)
end
step 'I remove user "John Doe" from group' do
diff --git a/features/steps/admin/users.rb b/features/steps/admin/users.rb
index 49e64eeff71..2e17d5c4c2e 100644
--- a/features/steps/admin/users.rb
+++ b/features/steps/admin/users.rb
@@ -79,7 +79,7 @@ class Spinach::Features::AdminUsers < Spinach::FeatureSteps
project.team << [user, :developer]
group = create(:group)
- group.add_user(user, Gitlab::Access::DEVELOPER)
+ group.add_developer(user)
end
step 'click on "Mike" link' do
diff --git a/features/steps/explore/groups.rb b/features/steps/explore/groups.rb
index 89b82293ef2..87cd33c37eb 100644
--- a/features/steps/explore/groups.rb
+++ b/features/steps/explore/groups.rb
@@ -19,7 +19,7 @@ class Spinach::Features::ExploreGroups < Spinach::FeatureSteps
step '"John Doe" is owner of group "TestGroup"' do
group = Group.find_by(name: "TestGroup") || create(:group, name: "TestGroup")
user = create(:user, name: "John Doe")
- group.add_user(user, Gitlab::Access::OWNER)
+ group.add_owner(user)
end
step 'I visit group "TestGroup" page' do
diff --git a/features/steps/invites.rb b/features/steps/invites.rb
index d051cc3edc8..5e8feff5095 100644
--- a/features/steps/invites.rb
+++ b/features/steps/invites.rb
@@ -6,7 +6,7 @@ class Spinach::Features::Invites < Spinach::FeatureSteps
step '"John Doe" has invited "user@example.com" to group "Owned"' do
user = User.find_by(name: "John Doe")
group = Group.find_by(name: "Owned")
- group.add_user("user@example.com", Gitlab::Access::DEVELOPER, user)
+ group.add_developer("user@example.com", user)
end
step 'I visit the invitation page' do
diff --git a/spec/finders/projects_finder_spec.rb b/spec/finders/projects_finder_spec.rb
index 2ab71b05968..de9d4cd6128 100644
--- a/spec/finders/projects_finder_spec.rb
+++ b/spec/finders/projects_finder_spec.rb
@@ -39,7 +39,7 @@ describe ProjectsFinder do
end
context 'authenticated, group member' do
- before { group.add_user(user, Gitlab::Access::DEVELOPER) }
+ before { group.add_developer(user) }
subject { ProjectsFinder.new.execute(user, group: group) }
diff --git a/spec/lib/gitlab/markdown/user_reference_filter_spec.rb b/spec/lib/gitlab/markdown/user_reference_filter_spec.rb
index 08e6941028f..9c55b4ff38f 100644
--- a/spec/lib/gitlab/markdown/user_reference_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/user_reference_filter_spec.rb
@@ -77,7 +77,7 @@ module Gitlab::Markdown
context 'that the current user can read' do
before do
- group.add_user(user, Gitlab::Access::DEVELOPER)
+ group.add_developer(user)
end
it 'links to the Group' do
diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb
index 4175f9dd88f..02d2cc2c77a 100644
--- a/spec/models/hooks/system_hook_spec.rb
+++ b/spec/models/hooks/system_hook_spec.rb
@@ -101,7 +101,7 @@ describe SystemHook do
it 'group member create hook' do
group = create(:group)
user = create(:user)
- group.add_user(user, Gitlab::Access::MASTER)
+ group.add_master(user)
expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_add_to_group/,
headers: { 'Content-Type'=>'application/json', 'X-Gitlab-Event'=>'System Hook' }
@@ -111,7 +111,7 @@ describe SystemHook do
it 'group member destroy hook' do
group = create(:group)
user = create(:user)
- group.add_user(user, Gitlab::Access::MASTER)
+ group.add_master(user)
group.group_members.destroy_all
expect(WebMock).to have_requested(:post, @system_hook.url).with(
body: /user_remove_from_group/,
diff --git a/spec/models/project_team_spec.rb b/spec/models/project_team_spec.rb
index d125166e336..cc1138490a0 100644
--- a/spec/models/project_team_spec.rb
+++ b/spec/models/project_team_spec.rb
@@ -37,9 +37,9 @@ describe ProjectTeam do
let(:project) { create(:empty_project, group: group) }
before do
- group.add_user(master, Gitlab::Access::MASTER)
- group.add_user(reporter, Gitlab::Access::REPORTER)
- group.add_user(guest, Gitlab::Access::GUEST)
+ group.add_master(master)
+ group.add_reporter(reporter)
+ group.add_guest(guest)
# If user is a group and a project member - GitLab uses highest permission
# So we add group guest as master and add group master as guest
diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb
index c5a4ac7e4c4..1d5b4f6f36b 100644
--- a/spec/requests/api/groups_spec.rb
+++ b/spec/requests/api/groups_spec.rb
@@ -135,7 +135,7 @@ describe API::API, api: true do
it "should not remove a group if not an owner" do
user4 = create(:user)
- group1.add_user(user4, Gitlab::Access::MASTER)
+ group1.add_master(user4)
delete api("/groups/#{group1.id}", user3)
expect(response.status).to eq(403)
end
diff --git a/spec/support/markdown_feature.rb b/spec/support/markdown_feature.rb
index 2a868aed73b..c59df4e84d6 100644
--- a/spec/support/markdown_feature.rb
+++ b/spec/support/markdown_feature.rb
@@ -17,7 +17,7 @@ class MarkdownFeature
def group
unless @group
@group = create(:group)
- @group.add_user(user, Gitlab::Access::DEVELOPER)
+ @group.add_developer(user)
end
@group