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
Léo-Paul Géneau
gitlab-ce
Commits
68c730bb
Commit
68c730bb
authored
Dec 23, 2016
by
Jose Ivan Vargas
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed rspec tests for the project members also fixed the index
view (removed an extra tag )
parent
4cd139e9
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
24 additions
and
68 deletions
+24
-68
app/controllers/projects/project_members_controller.rb
app/controllers/projects/project_members_controller.rb
+1
-42
app/views/projects/project_members/_index.html.haml
app/views/projects/project_members/_index.html.haml
+1
-5
app/views/projects/project_members/_new_project_member.html.haml
...ws/projects/project_members/_new_project_member.html.haml
+1
-1
spec/controllers/projects/project_members_controller_spec.rb
spec/controllers/projects/project_members_controller_spec.rb
+7
-7
spec/features/projects/members/anonymous_user_sees_members_spec.rb
...ures/projects/members/anonymous_user_sees_members_spec.rb
+2
-2
spec/features/projects/members/group_members_spec.rb
spec/features/projects/members/group_members_spec.rb
+4
-4
spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb
...s/members/master_adds_member_with_expiration_date_spec.rb
+2
-1
spec/features/security/project/internal_access_spec.rb
spec/features/security/project/internal_access_spec.rb
+2
-2
spec/features/security/project/private_access_spec.rb
spec/features/security/project/private_access_spec.rb
+2
-2
spec/features/security/project/public_access_spec.rb
spec/features/security/project/public_access_spec.rb
+2
-2
No files found.
app/controllers/projects/project_members_controller.rb
View file @
68c730bb
...
...
@@ -6,48 +6,7 @@ class Projects::ProjectMembersController < Projects::ApplicationController
before_action
:authorize_admin_project_member!
,
except:
[
:index
,
:leave
,
:request_access
]
def
index
@sort
=
params
[
:sort
].
presence
||
sort_value_name
@group_links
=
@project
.
project_group_links
@project_members
=
@project
.
project_members
@project_members
=
@project_members
.
non_invite
unless
can?
(
current_user
,
:admin_project
,
@project
)
group
=
@project
.
group
if
group
# We need `.where.not(user_id: nil)` here otherwise when a group has an
# invitee, it would make the following query return 0 rows since a NULL
# user_id would be present in the subquery
# See http://stackoverflow.com/questions/129077/not-in-clause-and-null-values
# FIXME: This whole logic should be moved to a finder!
non_null_user_ids
=
@project_members
.
where
.
not
(
user_id:
nil
).
select
(
:user_id
)
group_members
=
group
.
group_members
.
where
.
not
(
user_id:
non_null_user_ids
)
group_members
=
group_members
.
non_invite
unless
can?
(
current_user
,
:admin_group
,
@group
)
end
if
params
[
:search
].
present?
user_ids
=
@project
.
users
.
search
(
params
[
:search
]).
select
(
:id
)
@project_members
=
@project_members
.
where
(
user_id:
user_ids
)
if
group_members
user_ids
=
group
.
users
.
search
(
params
[
:search
]).
select
(
:id
)
group_members
=
group_members
.
where
(
user_id:
user_ids
)
end
@group_links
=
@project
.
project_group_links
.
where
(
group_id:
@project
.
invited_groups
.
search
(
params
[
:search
]).
select
(
:id
))
end
wheres
=
[
"members.id IN (
#{
@project_members
.
select
(
:id
).
to_sql
}
)"
]
wheres
<<
"members.id IN (
#{
group_members
.
select
(
:id
).
to_sql
}
)"
if
group_members
@project_members
=
Member
.
where
(
wheres
.
join
(
' OR '
)).
sort
(
@sort
).
page
(
params
[
:page
])
@requesters
=
AccessRequestsFinder
.
new
(
@project
).
execute
(
current_user
)
@project_member
=
@project
.
project_members
.
new
redirect_to
namespace_project_settings_members_path
(
@project
.
namespace
,
@project
)
end
def
create
...
...
app/views/projects/project_members/_index.html.haml
View file @
68c730bb
...
...
@@ -17,11 +17,7 @@
%h5
.member.existing-title
Existing users and groups
-
if
@group_links
.
any?
=
render
'groups'
,
group_links:
@group_links
.append-bottom-default.clearfix
-
if
@group_links
.
any?
=
render
'groups'
,
group_links:
@group_links
=
render
'projects/project_members/groups'
,
group_links:
@group_links
=
render
'projects/project_members/team'
,
members:
@project_members
=
paginate
@project_members
,
theme:
"gitlab"
app/views/projects/project_members/_new_project_member.html.haml
View file @
68c730bb
=
form_for
@project_member
,
as: :project_member
,
url:
namespace_project_
settings
_members_path
(
@project
.
namespace
,
@project
),
html:
{
class:
'users-project-form'
}
do
|
f
|
=
form_for
@project_member
,
as: :project_member
,
url:
namespace_project_
project
_members_path
(
@project
.
namespace
,
@project
),
html:
{
class:
'users-project-form'
}
do
|
f
|
.row
.col-md-5.col-lg-5
=
users_select_tag
(
:user_ids
,
multiple:
true
,
class:
"input-clamp"
,
scope: :all
,
email_user:
true
)
...
...
spec/controllers/projects/project_members_controller_spec.rb
View file @
68c730bb
...
...
@@ -5,11 +5,11 @@ describe Projects::ProjectMembersController do
let
(
:project
)
{
create
(
:empty_project
,
:public
,
:access_requestable
)
}
describe
'GET index'
do
it
're
nders index with 200
status code'
do
it
're
directs to settings/members with 302
status code'
do
get
:index
,
namespace_id:
project
.
namespace
,
project_id:
project
expect
(
response
).
to
have_http_status
(
200
)
expect
(
response
).
to
re
nder_template
(
:index
)
expect
(
response
).
to
have_http_status
(
302
)
expect
(
response
).
to
re
direct_to
(
namespace_project_settings_members_path
(
project
.
namespace
,
project
)
)
end
end
...
...
@@ -44,7 +44,7 @@ describe Projects::ProjectMembersController do
access_level:
Gitlab
::
Access
::
GUEST
expect
(
response
).
to
set_flash
.
to
'Users were successfully added.'
expect
(
response
).
to
redirect_to
(
namespace_project_
project
_members_path
(
project
.
namespace
,
project
))
expect
(
response
).
to
redirect_to
(
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
))
end
it
'adds no user to members'
do
...
...
@@ -56,7 +56,7 @@ describe Projects::ProjectMembersController do
access_level:
Gitlab
::
Access
::
GUEST
expect
(
response
).
to
set_flash
.
to
'No users or groups specified.'
expect
(
response
).
to
redirect_to
(
namespace_project_
project
_members_path
(
project
.
namespace
,
project
))
expect
(
response
).
to
redirect_to
(
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
))
end
end
end
...
...
@@ -99,7 +99,7 @@ describe Projects::ProjectMembersController do
id:
member
expect
(
response
).
to
redirect_to
(
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
)
expect
(
project
.
members
).
not_to
include
member
end
...
...
@@ -259,7 +259,7 @@ describe Projects::ProjectMembersController do
expect
(
project
.
team_members
).
to
include
member
expect
(
response
).
to
set_flash
.
to
'Successfully imported'
expect
(
response
).
to
redirect_to
(
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
)
end
end
...
...
spec/features/projects/members/anonymous_user_sees_members_spec.rb
View file @
68c730bb
...
...
@@ -11,10 +11,10 @@ feature 'Projects > Members > Anonymous user sees members', feature: true do
end
scenario
"anonymous user visits the project's members page and sees the list of members"
do
visit
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
visit
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
expect
(
current_path
).
to
eq
(
namespace_project_
project
_members_path
(
project
.
namespace
,
project
))
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
))
expect
(
page
).
to
have_content
(
user
.
name
)
end
end
spec/features/projects/members/group_members_spec.rb
View file @
68c730bb
...
...
@@ -19,7 +19,7 @@ feature 'Projects members', feature: true do
context
'with a group invitee'
do
before
do
group_invitee
visit
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
visit
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
end
scenario
'does not appear in the project members page'
do
...
...
@@ -33,7 +33,7 @@ feature 'Projects members', feature: true do
before
do
group_invitee
project_invitee
visit
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
visit
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
end
scenario
'shows the project invitee, the project developer, and the group owner'
do
...
...
@@ -54,7 +54,7 @@ feature 'Projects members', feature: true do
context
'with a group requester'
do
before
do
group
.
request_access
(
group_requester
)
visit
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
visit
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
end
scenario
'does not appear in the project members page'
do
...
...
@@ -68,7 +68,7 @@ feature 'Projects members', feature: true do
before
do
group
.
request_access
(
group_requester
)
project
.
request_access
(
project_requester
)
visit
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
visit
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
end
scenario
'shows the project requester, the project developer, and the group owner'
do
...
...
spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb
View file @
68c730bb
...
...
@@ -16,7 +16,8 @@ feature 'Projects > Members > Master adds member with expiration date', feature:
scenario
'expiration date is displayed in the members list'
do
travel_to
Time
.
zone
.
parse
(
'2016-08-06 08:00'
)
do
visit
namespace_project_project_members_path
(
project
.
namespace
,
project
)
visit
namespace_project_settings_members_path
(
project
.
namespace
,
project
)
save_screenshot
page
.
within
'.users-project-form'
do
select2
(
new_member
.
id
,
from:
'#user_ids'
,
multiple:
true
)
...
...
spec/features/security/project/internal_access_spec.rb
View file @
68c730bb
...
...
@@ -82,8 +82,8 @@ describe "Internal Project Access", feature: true do
it
{
is_expected
.
to
be_denied_for
(
:visitor
)
}
end
describe
"GET /:project_path/project_members"
do
subject
{
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
}
describe
"GET /:project_path/
settings/
project_members"
do
subject
{
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
}
it
{
is_expected
.
to
be_allowed_for
(
:admin
)
}
it
{
is_expected
.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
...
...
spec/features/security/project/private_access_spec.rb
View file @
68c730bb
...
...
@@ -82,8 +82,8 @@ describe "Private Project Access", feature: true do
it
{
is_expected
.
to
be_denied_for
(
:visitor
)
}
end
describe
"GET /:project_path/project_members"
do
subject
{
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
}
describe
"GET /:project_path/
settings/
project_members"
do
subject
{
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
}
it
{
is_expected
.
to
be_allowed_for
(
:admin
)
}
it
{
is_expected
.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
...
...
spec/features/security/project/public_access_spec.rb
View file @
68c730bb
...
...
@@ -82,8 +82,8 @@ describe "Public Project Access", feature: true do
it
{
is_expected
.
to
be_allowed_for
(
:visitor
)
}
end
describe
"GET /:project_path/project_members"
do
subject
{
namespace_project_
project
_members_path
(
project
.
namespace
,
project
)
}
describe
"GET /:project_path/
settings/
project_members"
do
subject
{
namespace_project_
settings
_members_path
(
project
.
namespace
,
project
)
}
it
{
is_expected
.
to
be_allowed_for
(
:admin
)
}
it
{
is_expected
.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
...
...
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