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
1337a014
Commit
1337a014
authored
Dec 03, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix ClustersController specs
parent
b2b4f262
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
79 additions
and
68 deletions
+79
-68
spec/controllers/projects/clusters_controller_spec.rb
spec/controllers/projects/clusters_controller_spec.rb
+79
-68
No files found.
spec/controllers/projects/clusters_controller_spec.rb
View file @
1337a014
...
@@ -16,14 +16,12 @@ describe Projects::ClustersController do
...
@@ -16,14 +16,12 @@ describe Projects::ClustersController do
end
end
context
'when project has a cluster'
do
context
'when project has a cluster'
do
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
let
!
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
it
{
expect
(
go
).
to
redirect_to
(
project_cluster_path
(
project
,
project
.
cluster
))
}
it
{
expect
(
go
).
to
redirect_to
(
project_cluster_path
(
project
,
project
.
cluster
))
}
end
end
context
'when project does not have a cluster'
do
context
'when project does not have a cluster'
do
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
)
}
it
{
expect
(
go
).
to
redirect_to
(
new_project_cluster_path
(
project
))
}
it
{
expect
(
go
).
to
redirect_to
(
new_project_cluster_path
(
project
))
}
end
end
end
end
...
@@ -124,41 +122,44 @@ describe Projects::ClustersController do
...
@@ -124,41 +122,44 @@ describe Projects::ClustersController do
describe
'PUT update'
do
describe
'PUT update'
do
context
'Managed'
do
context
'Managed'
do
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
let
(
:user
)
{
create
(
:user
)
}
describe
'functionality'
do
before
do
let
(
:user
)
{
create
(
:user
)
}
project
.
add_master
(
user
)
sign_in
(
user
)
before
do
end
project
.
add_master
(
user
)
sign_in
(
user
)
end
context
'when update enabled'
do
context
'when changing parameters'
do
let
(
:params
)
do
let
(
:params
)
do
{
{
cluster:
{
enabled:
false
}
cluster:
{
enabled:
false
,
name:
'my-new-cluster-name'
,
platform_kubernetes_attributes:
{
namespace:
'my-namespace'
}
}
}
end
}
end
it
"updates and redirects back to show page"
do
it
"updates and redirects back to show page"
do
go
go
cluster
.
reload
cluster
.
reload
expect
(
response
).
to
redirect_to
(
project_cluster_path
(
project
,
project
.
cluster
))
expect
(
response
).
to
redirect_to
(
project_cluster_path
(
project
,
project
.
cluster
))
expect
(
flash
[
:notice
]).
to
eq
(
'Cluster was successfully updated.'
)
expect
(
flash
[
:notice
]).
to
eq
(
'Cluster was successfully updated.'
)
expect
(
cluster
.
enabled
).
to
be_falsey
expect
(
cluster
.
enabled
).
to
be_falsey
end
end
context
'when cluster is being created'
do
context
'when cluster is being created'
do
let
(
:cluster
)
{
create
(
:cluster
,
:providing_by_gcp
,
projects:
[
project
])
}
let
(
:cluster
)
{
create
(
:cluster
,
:providing_by_gcp
,
projects:
[
project
])
}
it
"rejects changes"
do
it
"rejects changes"
do
go
go
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
have_gitlab_http_status
(
:ok
)
expect
(
response
).
to
render_template
(
:show
)
expect
(
response
).
to
render_template
(
:show
)
expect
(
cluster
.
enabled
).
to
be_truthy
expect
(
cluster
.
enabled
).
to
be_truthy
end
end
end
end
end
end
end
...
@@ -166,7 +167,7 @@ describe Projects::ClustersController do
...
@@ -166,7 +167,7 @@ describe Projects::ClustersController do
context
'User'
do
context
'User'
do
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_user
,
projects:
[
project
])
}
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_user
,
projects:
[
project
])
}
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
before
do
before
do
project
.
add_master
(
user
)
project
.
add_master
(
user
)
...
@@ -177,10 +178,11 @@ describe Projects::ClustersController do
...
@@ -177,10 +178,11 @@ describe Projects::ClustersController do
let
(
:params
)
do
let
(
:params
)
do
{
{
cluster:
{
cluster:
{
enabled:
false
,
name:
'my-new-cluster-name'
,
enabled:
false
,
platform_kubernetes_attributes:
[
name:
'my-new-cluster-name'
,
platform_kubernetes_attributes:
{
namespace:
'my-namespace'
namespace:
'my-namespace'
]
}
}
}
}
}
end
end
...
@@ -211,10 +213,10 @@ describe Projects::ClustersController do
...
@@ -211,10 +213,10 @@ describe Projects::ClustersController do
end
end
describe
'security'
do
describe
'security'
do
set
(
:cluster
)
{
create
(
:cluster
,
:providing_by_gcp
,
projects:
[
project
])
}
let
(
:params
)
do
let
(
:params
)
do
{
{
cluster:
{
enabled:
false
}
}
cluster:
{
enabled:
false
}
}
end
end
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
...
@@ -228,15 +230,14 @@ describe Projects::ClustersController do
...
@@ -228,15 +230,14 @@ describe Projects::ClustersController do
end
end
def
go
def
go
put
:update
,
params
.
merge
(
namespace_id:
project
.
namespace
,
put
:update
,
params
.
merge
(
project_id:
project
,
namespace_id:
project
.
namespace
,
id:
cluster
)
project_id:
project
,
id:
cluster
)
end
end
end
end
describe
'delete update'
do
describe
'DELETE destroy'
do
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
describe
'functionality'
do
describe
'functionality'
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:user
)
{
create
(
:user
)
}
...
@@ -245,45 +246,55 @@ describe Projects::ClustersController do
...
@@ -245,45 +246,55 @@ describe Projects::ClustersController do
sign_in
(
user
)
sign_in
(
user
)
end
end
it
"destroys and redirects back to clusters list"
do
context
'GCP'
do
expect
{
go
}
context
'when cluster is created'
do
.
to
change
{
Clusters
::
Cluster
.
count
}.
by
(
-
1
)
let!
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
.
and
change
{
Clusters
::
Platforms
::
Kubernetes
.
count
}.
by
(
-
1
)
.
and
change
{
Clusters
::
Providers
::
Gcp
.
count
}.
by
(
-
1
)
expect
(
response
).
to
redirect_to
(
project_clusters_path
(
project
))
it
"destroys and redirects back to clusters list"
do
expect
(
flash
[
:notice
]).
to
eq
(
'Cluster integration was successfully removed.'
)
expect
{
go
}
end
.
to
change
{
Clusters
::
Cluster
.
count
}.
by
(
-
1
)
.
and
change
{
Clusters
::
Platforms
::
Kubernetes
.
count
}.
by
(
-
1
)
.
and
change
{
Clusters
::
Providers
::
Gcp
.
count
}.
by
(
-
1
)
expect
(
response
).
to
redirect_to
(
project_clusters_path
(
project
))
expect
(
flash
[
:notice
]).
to
eq
(
'Cluster integration was successfully removed.'
)
end
end
context
'when cluster is being created'
do
context
'when cluster is being created'
do
let
(
:cluster
)
{
create
(
:cluster
,
:providing_by_gcp
,
projects:
[
project
])
}
let!
(
:cluster
)
{
create
(
:cluster
,
:providing_by_gcp
,
projects:
[
project
])
}
it
"destroys and redirects back to clusters list"
do
it
"destroys and redirects back to clusters list"
do
expect
{
go
}
expect
{
go
}
.
to
change
{
Clusters
::
Cluster
.
count
}.
by
(
-
1
)
.
to
change
{
Clusters
::
Cluster
.
count
}.
by
(
-
1
)
.
and
change
{
Clusters
::
Providers
::
Gcp
.
count
}.
by
(
-
1
)
.
and
change
{
Clusters
::
Providers
::
Gcp
.
count
}.
by
(
-
1
)
expect
(
response
).
to
redirect_to
(
project_clusters_path
(
project
))
expect
(
response
).
to
redirect_to
(
project_clusters_path
(
project
))
expect
(
flash
[
:notice
]).
to
eq
(
'Cluster integration was successfully removed.'
)
expect
(
flash
[
:notice
]).
to
eq
(
'Cluster integration was successfully removed.'
)
end
end
end
end
end
context
'when provider is user'
do
context
'User'
do
let
(
:cluster
)
{
create
(
:cluster
,
:provided_by_user
,
projects:
[
project
])
}
context
'when provider is user'
do
let!
(
:cluster
)
{
create
(
:cluster
,
:provided_by_user
,
projects:
[
project
])
}
it
"destroys and redirects back to clusters list"
do
it
"destroys and redirects back to clusters list"
do
expect
{
go
}
expect
{
go
}
.
to
change
{
Clusters
::
Cluster
.
count
}.
by
(
-
1
)
.
to
change
{
Clusters
::
Cluster
.
count
}.
by
(
-
1
)
.
and
change
{
Clusters
::
Platforms
::
Kubernetes
.
count
}.
by
(
-
1
)
.
and
change
{
Clusters
::
Platforms
::
Kubernetes
.
count
}.
by
(
-
1
)
.
and
change
{
Clusters
::
Providers
::
Gcp
.
count
}.
by
(
0
)
.
and
change
{
Clusters
::
Providers
::
Gcp
.
count
}.
by
(
0
)
expect
(
response
).
to
redirect_to
(
project_clusters_path
(
project
))
expect
(
response
).
to
redirect_to
(
project_clusters_path
(
project
))
expect
(
flash
[
:notice
]).
to
eq
(
'Cluster integration was successfully removed.'
)
expect
(
flash
[
:notice
]).
to
eq
(
'Cluster integration was successfully removed.'
)
end
end
end
end
end
end
end
describe
'security'
do
describe
'security'
do
set
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:admin
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:owner
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:master
).
of
(
project
)
}
it
{
expect
{
go
}.
to
be_allowed_for
(
:master
).
of
(
project
)
}
...
...
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