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
Jérome Perrin
gitlab-ce
Commits
67cc6b06
Commit
67cc6b06
authored
Dec 01, 2015
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Signed in admin should be able to add/remove himself to a project
parent
9ab7bdf7
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
55 additions
and
4 deletions
+55
-4
app/models/ability.rb
app/models/ability.rb
+2
-4
features/admin/projects.feature
features/admin/projects.feature
+16
-0
features/steps/admin/projects.rb
features/steps/admin/projects.rb
+37
-0
No files found.
app/models/ability.rb
View file @
67cc6b06
...
...
@@ -365,12 +365,10 @@ class Ability
unless
target_user
==
project
.
owner
can_manage
=
project_abilities
(
user
,
project
).
include?
(
:admin_project_member
)
if
can_manage
&&
user
!=
target_user
if
can_manage
rules
<<
:update_project_member
rules
<<
:destroy_project_member
end
if
user
==
target_user
elsif
user
==
target_user
rules
<<
:destroy_project_member
end
end
...
...
features/admin/projects.feature
View file @
67cc6b06
...
...
@@ -27,3 +27,19 @@ Feature: Admin Projects
And
I visit admin project page
When
I transfer project to group 'Web'
Then
I should see project transfered
@javascript
Scenario
:
Signed in admin should be able to add himself to a project
Given
"John Doe"
owns private project
"Enterprise"
When
I visit project
"Enterprise"
members page
When
I select current user as
"Developer"
Then
I should see current user as
"Developer"
@javascript
Scenario
:
Signed in admin should be able to remove himself from a project
Given
"John Doe"
owns private project
"Enterprise"
And
current user is developer of project
"Enterprise"
When
I visit project
"Enterprise"
members page
Then
I should see current user as
"Developer"
When
I click on the
"Remove User From Project"
button for current user
Then
I should not see current user as
"Developer"
features/steps/admin/projects.rb
View file @
67cc6b06
...
...
@@ -3,6 +3,8 @@ class Spinach::Features::AdminProjects < Spinach::FeatureSteps
include
SharedPaths
include
SharedAdmin
include
SharedProject
include
SharedUser
include
Select2Helper
step
'I should see all non-archived projects'
do
Project
.
non_archived
.
each
do
|
p
|
...
...
@@ -56,6 +58,41 @@ class Spinach::Features::AdminProjects < Spinach::FeatureSteps
expect
(
page
).
to
have_content
'Namespace: Web'
end
step
'I visit project "Enterprise" members page'
do
project
=
Project
.
find_by!
(
name:
"Enterprise"
)
visit
namespace_project_project_members_path
(
project
.
namespace
,
project
)
end
step
'I select current user as "Developer"'
do
page
.
within
".users-project-form"
do
select2
(
current_user
.
id
,
from:
"#user_ids"
,
multiple:
true
)
select
"Developer"
,
from:
"access_level"
end
click_button
"Add users to project"
end
step
'I should see current user as "Developer"'
do
page
.
within
'.content-list'
do
expect
(
page
).
to
have_content
(
current_user
.
name
)
expect
(
page
).
to
have_content
(
'Developer'
)
end
end
step
'current user is developer of project "Enterprise"'
do
project
=
Project
.
find_by!
(
name:
"Enterprise"
)
project
.
team
<<
[
current_user
,
:developer
]
end
step
'I click on the "Remove User From Project" button for current user'
do
find
(
:css
,
'li'
,
text:
current_user
.
name
).
find
(
:css
,
'a.btn-remove'
).
click
# poltergeist always confirms popups.
end
step
'I should not see current_user as "Developer"'
do
expect
(
page
).
not_to
have_selector
(
:css
,
'.content-list'
)
end
def
project
@project
||=
Project
.
first
end
...
...
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