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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
cc193d70
Commit
cc193d70
authored
Jul 16, 2014
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix 404 for invited projects
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
4e9f7c21
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
app/models/project_team.rb
app/models/project_team.rb
+20
-0
spec/models/project_team_spec.rb
spec/models/project_team_spec.rb
+19
-1
No files found.
app/models/project_team.rb
View file @
cc193d70
...
@@ -141,9 +141,29 @@ class ProjectTeam
...
@@ -141,9 +141,29 @@ class ProjectTeam
access
<<
group
.
users_groups
.
find_by
(
user_id:
user_id
).
try
(
:access_field
)
access
<<
group
.
users_groups
.
find_by
(
user_id:
user_id
).
try
(
:access_field
)
end
end
if
project
.
invited_groups
.
any?
access
<<
max_invited_level
(
user_id
)
end
access
.
compact
.
max
access
.
compact
.
max
end
end
def
max_invited_level
(
user_id
)
project
.
project_group_links
.
map
do
|
group_link
|
invited_group
=
group_link
.
group
access
=
invited_group
.
users_groups
.
find_by
(
user_id:
user_id
).
try
(
:access_field
)
# If group member has higher access level we should restrict it
# to max allowed access level
if
access
&&
access
>
group_link
.
group_access
access
=
group_link
.
group_access
end
access
end
.
compact
.
max
end
private
private
def
fetch_members
(
level
=
nil
)
def
fetch_members
(
level
=
nil
)
...
...
spec/models/project_team_spec.rb
View file @
cc193d70
...
@@ -62,5 +62,23 @@ describe ProjectTeam do
...
@@ -62,5 +62,23 @@ describe ProjectTeam do
it
{
project
.
team
.
master?
(
nonmember
).
should
be_false
}
it
{
project
.
team
.
master?
(
nonmember
).
should
be_false
}
end
end
end
end
end
describe
:max_invited_level
do
let
(
:group
)
{
create
(
:group
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
before
do
project
.
project_group_links
.
create
(
group:
group
,
group_access:
Gitlab
::
Access
::
DEVELOPER
)
group
.
add_user
(
master
,
Gitlab
::
Access
::
MASTER
)
group
.
add_user
(
reporter
,
Gitlab
::
Access
::
REPORTER
)
end
it
{
project
.
team
.
max_invited_level
(
master
.
id
).
should
==
Gitlab
::
Access
::
DEVELOPER
}
it
{
project
.
team
.
max_invited_level
(
reporter
.
id
).
should
==
Gitlab
::
Access
::
REPORTER
}
it
{
project
.
team
.
max_invited_level
(
nonmember
.
id
).
should
be_nil
}
end
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