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
c815990e
Commit
c815990e
authored
Jul 25, 2020
by
Peter Leitzen
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Speed up EE project policy specs
parent
2dbcb567
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
30 deletions
+31
-30
ee/spec/policies/project_policy_spec.rb
ee/spec/policies/project_policy_spec.rb
+31
-30
No files found.
ee/spec/policies/project_policy_spec.rb
View file @
c815990e
...
...
@@ -12,17 +12,26 @@ RSpec.describe ProjectPolicy do
let_it_be
(
:developer
)
{
create
(
:user
)
}
let_it_be
(
:reporter
)
{
create
(
:user
)
}
let_it_be
(
:guest
)
{
create
(
:user
)
}
let
(
:project
)
{
create
(
:project
,
:public
,
namespace:
owner
.
namespace
)
}
let_it_be
(
:non_member
)
{
create
(
:user
)
}
let_it_be
(
:project
,
refind:
true
)
{
create
(
:project
,
:public
,
namespace:
owner
.
namespace
)
}
let_it_be
(
:private_project
,
refind:
true
)
{
create
(
:project
,
:private
,
namespace:
owner
.
namespace
)
}
subject
{
described_class
.
new
(
current_user
,
project
)
}
before
do
stub_licensed_features
(
group_saml:
true
)
stub_licensed_features
(
license_scanning:
true
)
end
before_all
do
project
.
add_maintainer
(
maintainer
)
project
.
add_developer
(
developer
)
project
.
add_reporter
(
reporter
)
project
.
add_guest
(
guest
)
stub_licensed_features
(
license_scanning:
true
)
private_project
.
add_maintainer
(
maintainer
)
private_project
.
add_developer
(
developer
)
private_project
.
add_reporter
(
reporter
)
private_project
.
add_guest
(
guest
)
end
context
'basic permissions'
do
...
...
@@ -161,7 +170,7 @@ RSpec.describe ProjectPolicy do
end
context
'when user is not a member'
do
let
(
:current_user
)
{
build
(
:user
)
}
let
(
:current_user
)
{
non_member
}
it
{
is_expected
.
to
be_allowed
(
:read_iteration
)
}
it
{
is_expected
.
to
be_disallowed
(
:create_iteration
,
:admin_iteration
)
}
...
...
@@ -175,17 +184,10 @@ RSpec.describe ProjectPolicy do
end
context
'when the project is private'
do
let
(
:project
)
{
create
(
:project
,
:private
,
namespace:
owner
.
namespace
)
}
before
do
project
.
add_maintainer
(
maintainer
)
project
.
add_developer
(
developer
)
project
.
add_reporter
(
reporter
)
project
.
add_guest
(
guest
)
end
let
(
:project
)
{
private_project
}
context
'when user is not a member'
do
let
(
:current_user
)
{
build
(
:user
)
}
let
(
:current_user
)
{
non_member
}
it
{
is_expected
.
to
be_disallowed
(
:read_iteration
,
:create_iteration
,
:admin_iteration
)
}
end
...
...
@@ -200,7 +202,7 @@ RSpec.describe ProjectPolicy do
end
context
'issues feature'
do
subject
{
described_class
.
new
(
owner
,
project
)
}
let
(
:current_user
)
{
owner
}
context
'when the feature is disabled'
do
before
do
...
...
@@ -330,6 +332,7 @@ RSpec.describe ProjectPolicy do
let
(
:project
)
{
create
(
:project
,
group:
saml_provider
.
group
)
}
before
do
stub_licensed_features
(
group_saml:
true
)
group
.
add_guest
(
current_user
)
end
...
...
@@ -451,8 +454,6 @@ RSpec.describe ProjectPolicy do
end
describe
'vulnerability feedback permissions'
do
subject
{
described_class
.
new
(
current_user
,
project
)
}
where
(
permission:
%i[
read_vulnerability_feedback
create_vulnerability_feedback
...
...
@@ -504,7 +505,7 @@ RSpec.describe ProjectPolicy do
end
context
'with non member'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
non_member
}
it
{
is_expected
.
to
be_disallowed
(
permission
)
}
end
...
...
@@ -586,8 +587,8 @@ RSpec.describe ProjectPolicy do
end
end
context
'with no
t
member'
do
let
(
:current_user
)
{
create
(
:user
)
}
context
'with no
n
member'
do
let
(
:current_user
)
{
non_member
}
it
{
is_expected
.
to
be_disallowed
(
:read_threat_monitoring
)
}
end
...
...
@@ -722,7 +723,7 @@ RSpec.describe ProjectPolicy do
end
context
'with non member'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
non_member
}
it
{
is_expected
.
to
be_disallowed
(
:admin_software_license_policy
)
}
end
...
...
@@ -769,7 +770,7 @@ RSpec.describe ProjectPolicy do
end
context
'with private project'
do
let
(
:project
)
{
create
(
:project
,
:private
,
namespace:
owner
.
namespace
)
}
let
(
:project
)
{
private_project
}
context
'with admin'
do
let
(
:current_user
)
{
admin
}
...
...
@@ -813,8 +814,8 @@ RSpec.describe ProjectPolicy do
it
{
is_expected
.
to
be_disallowed
(
:read_dependencies
)
}
end
context
'with no
t
member'
do
let
(
:current_user
)
{
create
(
:user
)
}
context
'with no
n
member'
do
let
(
:current_user
)
{
non_member
}
it
{
is_expected
.
to
be_disallowed
(
:read_dependencies
)
}
end
...
...
@@ -837,7 +838,7 @@ RSpec.describe ProjectPolicy do
describe
'read_licenses'
do
context
'when license management feature available'
do
context
'with public project'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
non_member
}
context
'with public access to repository'
do
it
{
is_expected
.
to
be_allowed
(
:read_licenses
)
}
...
...
@@ -845,7 +846,7 @@ RSpec.describe ProjectPolicy do
end
context
'with private project'
do
let
(
:project
)
{
create
(
:project
,
:private
,
namespace:
owner
.
namespace
)
}
let
(
:project
)
{
private_project
}
where
(
role:
%w[owner maintainer developer reporter]
)
...
...
@@ -873,8 +874,8 @@ RSpec.describe ProjectPolicy do
it
{
is_expected
.
to
be_disallowed
(
:read_licenses
)
}
end
context
'with no
t
member'
do
let
(
:current_user
)
{
create
(
:user
)
}
context
'with no
n
member'
do
let
(
:current_user
)
{
non_member
}
it
{
is_expected
.
to
be_disallowed
(
:read_licenses
)
}
end
...
...
@@ -1139,7 +1140,7 @@ RSpec.describe ProjectPolicy do
end
context
'with non member'
do
let
(
:current_user
)
{
create
(
:user
)
}
let
(
:current_user
)
{
non_member
}
it
{
is_expected
.
to
be_disallowed
(
:read_group_timelogs
)
}
end
...
...
@@ -1162,7 +1163,7 @@ RSpec.describe ProjectPolicy do
end
describe
':read_code_review_analytics'
do
let
(
:project
)
{
create
(
:project
,
namespace:
owner
.
namespace
)
}
let
(
:project
)
{
private_project
}
using
RSpec
::
Parameterized
::
TableSyntax
...
...
@@ -1199,7 +1200,7 @@ RSpec.describe ProjectPolicy do
end
shared_examples
'merge request rules'
do
let
(
:project
)
{
create
(
:project
,
namespace:
owner
.
namespace
)
}
let
(
:project
)
{
private_project
}
using
RSpec
::
Parameterized
::
TableSyntax
...
...
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