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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
5fb8b2f7
Commit
5fb8b2f7
authored
Dec 01, 2017
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor disabled cluster testing to use trait
parent
f6057437
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
12 deletions
+14
-12
spec/controllers/projects/clusters_controller_spec.rb
spec/controllers/projects/clusters_controller_spec.rb
+3
-3
spec/factories/clusters/cluster.rb
spec/factories/clusters/cluster.rb
+4
-0
spec/finders/clusters_finder_spec.rb
spec/finders/clusters_finder_spec.rb
+7
-9
No files found.
spec/controllers/projects/clusters_controller_spec.rb
View file @
5fb8b2f7
...
...
@@ -15,15 +15,15 @@ describe Projects::ClustersController do
context
'when project has one or more clusters'
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:
clusters
)
{
create_list
(
:cluster
,
2
,
:provided_by_gcp
,
projects:
[
project
])
}
let
(
:
inactive_cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
let
(
:
enabled_cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
let
(
:
disabled_cluster
)
{
create
(
:cluster
,
:disabled
,
:provided_by_gcp
,
projects:
[
project
])
}
it
'lists available clusters'
do
go
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:index
)
expect
(
assigns
(
:clusters
)).
to
match_array
(
clusters
)
expect
(
assigns
(
:clusters
)).
to
match_array
(
[
enabled_cluster
,
disabled_cluster
]
)
end
it
'assigns counters to correct values'
do
...
...
spec/factories/clusters/cluster.rb
View file @
5fb8b2f7
...
...
@@ -35,5 +35,9 @@ FactoryGirl.define do
create
(
:cluster_provider_gcp
,
:creating
)
end
end
trait
:disabled
do
enabled
false
end
end
end
spec/finders/clusters_finder_spec.rb
View file @
5fb8b2f7
...
...
@@ -5,29 +5,27 @@ describe ClustersFinder do
set
(
:user
)
{
create
(
:user
)
}
describe
'#execute'
do
before
do
create_list
(
:cluster
,
2
,
:provided_by_gcp
,
projects:
[
project
])
project
.
clusters
.
last
.
enabled
=
false
end
let
(
:enabled_cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
let
(
:disabled_cluster
)
{
create
(
:cluster
,
:disabled
,
:provided_by_gcp
,
projects:
[
project
])
}
subject
{
described_class
.
new
(
project
,
user
,
scope
).
execute
}
context
'when scope is all'
do
let
(
:scope
)
{
:all
}
it
{
is_expected
.
to
eq
(
project
.
clusters
)
}
it
{
is_expected
.
to
match_array
([
enabled_cluster
,
disabled_cluster
]
)
}
end
context
'when scope is
enabled
'
do
context
'when scope is
active
'
do
let
(
:scope
)
{
:active
}
it
{
is_expected
.
to
eq
(
project
.
clusters
.
enabled
)
}
it
{
is_expected
.
to
match_array
([
enabled_cluster
]
)
}
end
context
'when scope is
disabled
'
do
context
'when scope is
inactive
'
do
let
(
:scope
)
{
:inactive
}
it
{
is_expected
.
to
eq
(
project
.
clusters
.
disabled
)
}
it
{
is_expected
.
to
match_array
([
disabled_cluster
]
)
}
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