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
dddd2db7
Commit
dddd2db7
authored
Apr 13, 2020
by
Hordur Freyr Yngvason
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor error case into shared examples
parent
619d7d69
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
9 deletions
+9
-9
spec/services/clusters/create_service_spec.rb
spec/services/clusters/create_service_spec.rb
+9
-9
No files found.
spec/services/clusters/create_service_spec.rb
View file @
dddd2db7
...
...
@@ -84,10 +84,8 @@ describe Clusters::CreateService do
let
(
:management_project_namespace
)
{
project
.
namespace
}
let
(
:management_project
)
{
create
(
:project
,
namespace:
management_project_namespace
)
}
context
'management_project is non-existent'
do
let
(
:management_project_id
)
{
0
}
it
'does not persist the cluster'
do
shared_examples
'invalid project or cluster permissions'
do
it
'does not persist the cluster and adds errors'
do
expect
(
cluster
).
not_to
be_persisted
expect
(
cluster
.
errors
[
:management_project_id
]).
to
include
(
'Project does not exist or you don\'t have permission to perform this action'
)
...
...
@@ -108,11 +106,7 @@ describe Clusters::CreateService do
end
context
'when user is not authorized to adminster manangement_project'
do
it
'does not persist the cluster'
do
expect
(
cluster
).
not_to
be_persisted
expect
(
cluster
.
errors
[
:management_project_id
]).
to
include
(
'Project does not exist or you don\'t have permission to perform this action'
)
end
include_examples
'invalid project or cluster permissions'
end
end
...
...
@@ -128,6 +122,12 @@ describe Clusters::CreateService do
end
end
context
'management_project is non-existent'
do
let
(
:management_project_id
)
{
0
}
include_examples
'invalid project or cluster permissions'
end
context
'project cluster'
do
include_examples
'setting a management project'
include_examples
'setting a management project outside of scope'
...
...
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