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
ce4b70ce
Commit
ce4b70ce
authored
5 years ago
by
Rémy Coutable
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Factorize policy helpers into PolicyHelpers
Signed-off-by:
Rémy Coutable
<
remy@rymai.me
>
parent
1983d05c
No related merge requests found
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
12 additions
and
32 deletions
+12
-32
spec/policies/board_policy_spec.rb
spec/policies/board_policy_spec.rb
+0
-8
spec/policies/group_policy_spec.rb
spec/policies/group_policy_spec.rb
+0
-8
spec/policies/project_snippet_policy_spec.rb
spec/policies/project_snippet_policy_spec.rb
+0
-8
spec/spec_helper.rb
spec/spec_helper.rb
+1
-0
spec/support/helpers/policy_helpers.rb
spec/support/helpers/policy_helpers.rb
+11
-0
spec/support/shared_context/policies/project_policy_shared_context.rb
.../shared_context/policies/project_policy_shared_context.rb
+0
-8
No files found.
spec/policies/board_policy_spec.rb
View file @
ce4b70ce
...
...
@@ -17,14 +17,6 @@ describe BoardPolicy do
]
end
def
expect_allowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
to
be_allowed
(
p
)
}
end
def
expect_disallowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
not_to
be_allowed
(
p
)
}
end
context
'group board'
do
subject
{
described_class
.
new
(
user
,
group_board
)
}
...
...
This diff is collapsed.
Click to expand it.
spec/policies/group_policy_spec.rb
View file @
ce4b70ce
...
...
@@ -51,14 +51,6 @@ describe GroupPolicy do
subject
{
described_class
.
new
(
current_user
,
group
)
}
def
expect_allowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
to
be_allowed
(
p
)
}
end
def
expect_disallowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
not_to
be_allowed
(
p
)
}
end
context
'with no user'
do
let
(
:group
)
{
create
(
:group
,
:public
)
}
let
(
:current_user
)
{
nil
}
...
...
This diff is collapsed.
Click to expand it.
spec/policies/project_snippet_policy_spec.rb
View file @
ce4b70ce
...
...
@@ -15,14 +15,6 @@ describe ProjectSnippetPolicy do
subject
{
described_class
.
new
(
current_user
,
snippet
)
}
def
expect_allowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
to
be_allowed
(
p
)
}
end
def
expect_disallowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
not_to
be_allowed
(
p
)
}
end
context
'public snippet'
do
let
(
:snippet_visibility
)
{
:public
}
...
...
This diff is collapsed.
Click to expand it.
spec/spec_helper.rb
View file @
ce4b70ce
...
...
@@ -96,6 +96,7 @@ RSpec.configure do |config|
config
.
include
MigrationsHelpers
,
:migration
config
.
include
RedisHelpers
config
.
include
Rails
.
application
.
routes
.
url_helpers
,
type: :routing
config
.
include
PolicyHelpers
,
type: :policy
if
ENV
[
'CI'
]
# This includes the first try, i.e. tests will be run 4 times before failing.
...
...
This diff is collapsed.
Click to expand it.
spec/support/helpers/policy_helpers.rb
0 → 100644
View file @
ce4b70ce
# frozen_string_literal: true
module
PolicyHelpers
def
expect_allowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
to
be_allowed
(
p
)
}
end
def
expect_disallowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
not_to
be_allowed
(
p
)
}
end
end
This diff is collapsed.
Click to expand it.
spec/support/shared_context/policies/project_policy_shared_context.rb
View file @
ce4b70ce
...
...
@@ -85,12 +85,4 @@ RSpec.shared_context 'ProjectPolicy context' do
project
.
add_developer
(
developer
)
project
.
add_reporter
(
reporter
)
end
def
expect_allowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
to
be_allowed
(
p
)
}
end
def
expect_disallowed
(
*
permissions
)
permissions
.
each
{
|
p
|
is_expected
.
not_to
be_allowed
(
p
)
}
end
end
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