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
bd5f2983
Commit
bd5f2983
authored
Dec 06, 2017
by
Matija Čupić
Committed by
Kamil Trzcinski
Dec 06, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add tests for EE logic in Clusters::CreateService
parent
5c1cba17
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
5 deletions
+36
-5
app/services/clusters/create_service.rb
app/services/clusters/create_service.rb
+3
-1
spec/services/clusters/create_service_spec.rb
spec/services/clusters/create_service_spec.rb
+33
-4
No files found.
app/services/clusters/create_service.rb
View file @
bd5f2983
...
...
@@ -29,7 +29,9 @@ module Clusters
end
def
can_create_cluster?
project
.
clusters
.
empty?
return
true
if
project
.
clusters
.
empty?
project
.
feature_available?
(
:multiple_clusters
)
end
end
end
spec/services/clusters/create_service_spec.rb
View file @
bd5f2983
...
...
@@ -82,12 +82,41 @@ describe Clusters::CreateService do
end
context
'when project has a cluster'
do
include_context
'valid params'
let!
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
it
'does not create a cluster'
do
expect
(
ClusterProvisionWorker
).
not_to
receive
(
:perform_async
)
expect
{
subject
}.
to
raise_error
(
ArgumentError
).
and
change
{
Clusters
::
Cluster
.
count
}.
by
(
0
)
before
do
allow
(
project
).
to
receive
(
:feature_available?
).
and_call_original
end
context
'when license has multiple clusters feature'
do
before
do
allow
(
project
).
to
receive
(
:feature_available?
).
with
(
:multiple_clusters
).
and_return
(
true
)
end
context
'when correct params'
do
include_context
'valid params'
include_examples
'create cluster'
end
context
'when invalid params'
do
include_context
'invalid params'
include_examples
'error'
end
end
context
'when license does not have multiple clusters feature'
do
include_context
'valid params'
before
do
allow
(
project
).
to
receive
(
:feature_available?
).
with
(
:multiple_clusters
).
and_return
(
false
)
end
it
'does not create a cluster'
do
expect
(
ClusterProvisionWorker
).
not_to
receive
(
:perform_async
)
expect
{
subject
}.
to
raise_error
(
ArgumentError
).
and
change
{
Clusters
::
Cluster
.
count
}.
by
(
0
)
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