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
29b1623a
Commit
29b1623a
authored
Aug 23, 2016
by
http://jneen.net/
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add project_policy_spec to replace .project_abilities spec
parent
e208765a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
64 deletions
+36
-64
spec/models/ability_spec.rb
spec/models/ability_spec.rb
+0
-64
spec/policies/project_policy_spec.rb
spec/policies/project_policy_spec.rb
+36
-0
No files found.
spec/models/ability_spec.rb
View file @
29b1623a
...
...
@@ -171,70 +171,6 @@ describe Ability, lib: true do
end
end
shared_examples_for
".project_abilities"
do
|
enable_request_store
|
before
do
RequestStore
.
begin!
if
enable_request_store
end
after
do
if
enable_request_store
RequestStore
.
end!
RequestStore
.
clear!
end
end
describe
'.project_abilities'
do
let!
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let!
(
:user
)
{
create
(
:user
)
}
it
'returns permissions for admin user'
do
admin
=
create
(
:admin
)
results
=
described_class
.
project_abilities
(
admin
,
project
)
expect
(
results
.
count
).
to
eq
(
68
)
end
it
'returns permissions for an owner'
do
results
=
described_class
.
project_abilities
(
project
.
owner
,
project
)
expect
(
results
.
count
).
to
eq
(
68
)
end
it
'returns permissions for a master'
do
project
.
team
<<
[
user
,
:master
]
results
=
described_class
.
project_abilities
(
user
,
project
)
expect
(
results
.
count
).
to
eq
(
60
)
end
it
'returns permissions for a developer'
do
project
.
team
<<
[
user
,
:developer
]
results
=
described_class
.
project_abilities
(
user
,
project
)
expect
(
results
.
count
).
to
eq
(
44
)
end
it
'returns permissions for a guest'
do
project
.
team
<<
[
user
,
:guest
]
results
=
described_class
.
project_abilities
(
user
,
project
)
expect
(
results
.
count
).
to
eq
(
21
)
end
end
end
describe
'.project_abilities with RequestStore'
do
it_behaves_like
".project_abilities"
,
true
end
describe
'.project_abilities without RequestStore'
do
it_behaves_like
".project_abilities"
,
false
end
describe
'.issues_readable_by_user'
do
context
'with an admin user'
do
it
'returns all given issues'
do
...
...
spec/policies/project_policy_spec.rb
0 → 100644
View file @
29b1623a
require
'spec_helper'
describe
ProjectPolicy
,
models:
true
do
let
(
:project
)
{
create
(
:empty_project
,
:public
)
}
let
(
:guest
)
{
create
(
:user
)
}
let
(
:reporter
)
{
create
(
:user
)
}
let
(
:dev
)
{
create
(
:user
)
}
let
(
:master
)
{
create
(
:user
)
}
let
(
:owner
)
{
create
(
:user
)
}
let
(
:admin
)
{
create
(
:admin
)
}
let
(
:users_ordered_by_permissions
)
do
[
nil
,
guest
,
reporter
,
dev
,
master
,
owner
,
admin
]
end
let
(
:users_permissions
)
do
users_ordered_by_permissions
.
map
{
|
u
|
Ability
.
allowed
(
u
,
project
).
size
}
end
before
do
project
.
team
<<
[
guest
,
:guest
]
project
.
team
<<
[
master
,
:master
]
project
.
team
<<
[
dev
,
:developer
]
project
.
team
<<
[
reporter
,
:reporter
]
group
=
create
(
:group
)
project
.
project_group_links
.
create
(
group:
group
,
group_access:
Gitlab
::
Access
::
MASTER
)
group
.
add_owner
(
owner
)
end
it
'returns increasing permissions for each level'
do
expect
(
users_permissions
).
to
eq
(
users_permissions
.
sort
.
uniq
)
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