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
Tatuya Kamada
gitlab-ce
Commits
68154e8f
Commit
68154e8f
authored
13 years ago
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
spec fix
parent
cb021e58
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
22 additions
and
13 deletions
+22
-13
app/models/project.rb
app/models/project.rb
+10
-1
spec/models/project_security_spec.rb
spec/models/project_security_spec.rb
+9
-9
spec/requests/projects_security_spec.rb
spec/requests/projects_security_spec.rb
+3
-3
No files found.
app/models/project.rb
View file @
68154e8f
...
...
@@ -114,9 +114,18 @@ class Project < ActiveRecord::Base
!!
commit
end
# Compatible with all access rights
# Should be rewrited for new access rights
def
add_access
(
user
,
*
access
)
access
=
if
access
.
include?
(
:admin
)
{
:project_access
=>
PROJECT_RWA
}
elsif
access
.
include?
(
:write
)
{
:project_access
=>
PROJECT_RW
}
else
{
:project_access
=>
PROJECT_R
}
end
opts
=
{
:user
=>
user
}
access
.
each
{
|
name
|
opts
.
merge!
(
name
=>
true
)
}
opts
.
merge!
(
access
)
users_projects
.
create
(
opts
)
end
...
...
This diff is collapsed.
Click to expand it.
spec/models/project_security_spec.rb
View file @
68154e8f
...
...
@@ -10,30 +10,30 @@ describe Project do
@abilities
<<
Ability
end
describe
:read
do
describe
"read access"
do
before
do
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u1
,
:
read
=>
false
)
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u2
,
:
read
=>
true
)
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u1
,
:
project_access
=>
Project
::
PROJECT_N
)
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u2
,
:
project_access
=>
Project
::
PROJECT_R
)
end
it
{
@abilities
.
allowed?
(
@u1
,
:read_project
,
@p1
).
should
be_false
}
it
{
@abilities
.
allowed?
(
@u2
,
:read_project
,
@p1
).
should
be_true
}
end
describe
:write
do
describe
"write access"
do
before
do
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u1
,
:
write
=>
false
)
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u2
,
:
write
=>
true
)
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u1
,
:
project_access
=>
Project
::
PROJECT_R
)
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u2
,
:
project_access
=>
Project
::
PROJECT_RW
)
end
it
{
@abilities
.
allowed?
(
@u1
,
:write_project
,
@p1
).
should
be_false
}
it
{
@abilities
.
allowed?
(
@u2
,
:write_project
,
@p1
).
should
be_true
}
end
describe
:admin
do
describe
"admin access"
do
before
do
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u1
,
:
admin
=>
false
)
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u2
,
:
admin
=>
true
)
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u1
,
:
project_access
=>
Project
::
PROJECT_RW
)
@p1
.
users_projects
.
create
(
:project
=>
@p1
,
:user
=>
@u2
,
:
project_access
=>
Project
::
PROJECT_RWA
)
end
it
{
@abilities
.
allowed?
(
@u1
,
:admin_project
,
@p1
).
should
be_false
}
...
...
This diff is collapsed.
Click to expand it.
spec/requests/projects_security_spec.rb
View file @
68154e8f
...
...
@@ -20,11 +20,11 @@ describe "Projects" do
@u2
=
Factory
:user
@u3
=
Factory
:user
# full access
@project
.
users_projects
.
create
(
:user
=>
@u1
,
:
read
=>
true
,
:write
=>
true
,
:admin
=>
true
)
@project
.
users_projects
.
create
(
:user
=>
@u1
,
:
project_access
=>
Project
::
PROJECT_RWA
)
# no access
@project
.
users_projects
.
create
(
:user
=>
@u2
,
:
read
=>
false
,
:write
=>
false
,
:admin
=>
false
)
@project
.
users_projects
.
create
(
:user
=>
@u2
,
:
project_access
=>
Project
::
PROJECT_N
)
# readonly
@project
.
users_projects
.
create
(
:user
=>
@u3
,
:
read
=>
true
,
:write
=>
false
,
:admin
=>
false
)
@project
.
users_projects
.
create
(
:user
=>
@u3
,
:
project_access
=>
Project
::
PROJECT_R
)
end
describe
"GET /project_code"
do
...
...
This diff is collapsed.
Click to expand it.
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