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
3c957c00
Commit
3c957c00
authored
Oct 13, 2016
by
Yorick Peterse
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added tests for IssuePolicy
parent
bad6d29f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
0 deletions
+119
-0
spec/policies/issue_policy_spec.rb
spec/policies/issue_policy_spec.rb
+119
-0
No files found.
spec/policies/issue_policy_spec.rb
0 → 100644
View file @
3c957c00
require
'spec_helper'
describe
IssuePolicy
,
models:
true
do
let
(
:user
)
{
create
(
:user
)
}
describe
'#rules'
do
context
'using a regular issue'
do
let
(
:project
)
{
create
(
:project
,
:public
)
}
let
(
:issue
)
{
create
(
:issue
,
project:
project
)
}
let
(
:policies
)
{
described_class
.
abilities
(
user
,
issue
).
to_set
}
context
'with a regular user'
do
it
'includes the read_issue permission'
do
expect
(
policies
).
to
include
(
:read_issue
)
end
it
'does not include the admin_issue permission'
do
expect
(
policies
).
not_to
include
(
:admin_issue
)
end
it
'does not include the update_issue permission'
do
expect
(
policies
).
not_to
include
(
:update_issue
)
end
end
context
'with a user that is a project reporter'
do
before
do
project
.
team
<<
[
user
,
:reporter
]
end
it
'includes the read_issue permission'
do
expect
(
policies
).
to
include
(
:read_issue
)
end
it
'includes the admin_issue permission'
do
expect
(
policies
).
to
include
(
:admin_issue
)
end
it
'includes the update_issue permission'
do
expect
(
policies
).
to
include
(
:update_issue
)
end
end
context
'with a user that is a project guest'
do
before
do
project
.
team
<<
[
user
,
:guest
]
end
it
'includes the read_issue permission'
do
expect
(
policies
).
to
include
(
:read_issue
)
end
it
'does not include the admin_issue permission'
do
expect
(
policies
).
not_to
include
(
:admin_issue
)
end
it
'does not include the update_issue permission'
do
expect
(
policies
).
not_to
include
(
:update_issue
)
end
end
end
context
'using a confidential issue'
do
let
(
:issue
)
{
create
(
:issue
,
:confidential
)
}
context
'with a regular user'
do
let
(
:policies
)
{
described_class
.
abilities
(
user
,
issue
).
to_set
}
it
'does not include the read_issue permission'
do
expect
(
policies
).
not_to
include
(
:read_issue
)
end
it
'does not include the admin_issue permission'
do
expect
(
policies
).
not_to
include
(
:admin_issue
)
end
it
'does not include the update_issue permission'
do
expect
(
policies
).
not_to
include
(
:update_issue
)
end
end
context
'with a user that is a project member'
do
let
(
:policies
)
{
described_class
.
abilities
(
user
,
issue
).
to_set
}
before
do
issue
.
project
.
team
<<
[
user
,
:reporter
]
end
it
'includes the read_issue permission'
do
expect
(
policies
).
to
include
(
:read_issue
)
end
it
'includes the admin_issue permission'
do
expect
(
policies
).
to
include
(
:admin_issue
)
end
it
'includes the update_issue permission'
do
expect
(
policies
).
to
include
(
:update_issue
)
end
end
context
'without a user'
do
let
(
:policies
)
{
described_class
.
abilities
(
nil
,
issue
).
to_set
}
it
'does not include the read_issue permission'
do
expect
(
policies
).
not_to
include
(
:read_issue
)
end
it
'does not include the admin_issue permission'
do
expect
(
policies
).
not_to
include
(
:admin_issue
)
end
it
'does not include the update_issue permission'
do
expect
(
policies
).
not_to
include
(
:update_issue
)
end
end
end
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