Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
fb6dc1f0
Commit
fb6dc1f0
authored
Aug 07, 2015
by
Robert Speicher
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add `Group#add_*` convenience methods
Encapsulates the logic for `Gitlab::Access::WHATEVER` levels.
parent
5fb5fd25
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
30 additions
and
14 deletions
+30
-14
app/models/group.rb
app/models/group.rb
+17
-1
features/steps/admin/groups.rb
features/steps/admin/groups.rb
+1
-1
features/steps/admin/users.rb
features/steps/admin/users.rb
+1
-1
features/steps/explore/groups.rb
features/steps/explore/groups.rb
+1
-1
features/steps/invites.rb
features/steps/invites.rb
+1
-1
spec/finders/projects_finder_spec.rb
spec/finders/projects_finder_spec.rb
+1
-1
spec/lib/gitlab/markdown/user_reference_filter_spec.rb
spec/lib/gitlab/markdown/user_reference_filter_spec.rb
+1
-1
spec/models/hooks/system_hook_spec.rb
spec/models/hooks/system_hook_spec.rb
+2
-2
spec/models/project_team_spec.rb
spec/models/project_team_spec.rb
+3
-3
spec/requests/api/groups_spec.rb
spec/requests/api/groups_spec.rb
+1
-1
spec/support/markdown_feature.rb
spec/support/markdown_feature.rb
+1
-1
No files found.
app/models/group.rb
View file @
fb6dc1f0
...
...
@@ -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
)
...
...
features/steps/admin/groups.rb
View file @
fb6dc1f0
...
...
@@ -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
...
...
features/steps/admin/users.rb
View file @
fb6dc1f0
...
...
@@ -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
...
...
features/steps/explore/groups.rb
View file @
fb6dc1f0
...
...
@@ -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
...
...
features/steps/invites.rb
View file @
fb6dc1f0
...
...
@@ -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
...
...
spec/finders/projects_finder_spec.rb
View file @
fb6dc1f0
...
...
@@ -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
)
}
...
...
spec/lib/gitlab/markdown/user_reference_filter_spec.rb
View file @
fb6dc1f0
...
...
@@ -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
...
...
spec/models/hooks/system_hook_spec.rb
View file @
fb6dc1f0
...
...
@@ -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/
,
...
...
spec/models/project_team_spec.rb
View file @
fb6dc1f0
...
...
@@ -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
...
...
spec/requests/api/groups_spec.rb
View file @
fb6dc1f0
...
...
@@ -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
...
...
spec/support/markdown_feature.rb
View file @
fb6dc1f0
...
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment