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
b3cdd336
Commit
b3cdd336
authored
Dec 18, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add test. Use readonly everywhere
parent
232b98b5
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
106 additions
and
25 deletions
+106
-25
app/views/projects/clusters/gcp/_form.html.haml
app/views/projects/clusters/gcp/_form.html.haml
+1
-1
app/views/projects/clusters/gcp/_show.html.haml
app/views/projects/clusters/gcp/_show.html.haml
+1
-1
app/views/projects/clusters/user/_form.html.haml
app/views/projects/clusters/user/_form.html.haml
+1
-1
app/views/projects/clusters/user/_show.html.haml
app/views/projects/clusters/user/_show.html.haml
+1
-1
spec/ee/spec/features/projects/clusters_spec.rb
spec/ee/spec/features/projects/clusters_spec.rb
+102
-21
No files found.
app/views/projects/clusters/gcp/_form.html.haml
View file @
b3cdd336
...
...
@@ -13,7 +13,7 @@
-
if
@project
.
feature_available?
(
:multiple_clusters
)
=
field
.
text_field
:environment_scope
,
class:
'form-control'
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
-
else
=
field
.
text_field
:environment_scope
,
class:
'form-control'
,
disabled
:
true
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
=
field
.
text_field
:environment_scope
,
class:
'form-control'
,
readonly
:
true
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
=
field
.
fields_for
:provider_gcp
,
@cluster
.
provider_gcp
do
|
provider_gcp_field
|
.form-group
...
...
app/views/projects/clusters/gcp/_show.html.haml
View file @
b3cdd336
...
...
@@ -14,7 +14,7 @@
-
if
@project
.
feature_available?
(
:multiple_clusters
)
=
field
.
text_field
:environment_scope
,
class:
'form-control js-select-on-focus'
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
-
else
=
field
.
text_field
:environment_scope
,
class:
'form-control js-select-on-focus'
,
disabled
:
true
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
=
field
.
text_field
:environment_scope
,
class:
'form-control js-select-on-focus'
,
readonly
:
true
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
=
field
.
fields_for
:platform_kubernetes
,
@cluster
.
platform_kubernetes
do
|
platform_kubernetes_field
|
.form-group
...
...
app/views/projects/clusters/user/_form.html.haml
View file @
b3cdd336
...
...
@@ -9,7 +9,7 @@
-
if
@project
.
feature_available?
(
:multiple_clusters
)
=
field
.
text_field
:environment_scope
,
class:
'form-control'
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
-
else
=
field
.
text_field
:environment_scope
,
class:
'form-control'
,
disabled
:
true
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
=
field
.
text_field
:environment_scope
,
class:
'form-control'
,
readonly
:
true
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
=
field
.
fields_for
:platform_kubernetes
,
@cluster
.
platform_kubernetes
do
|
platform_kubernetes_field
|
.form-group
...
...
app/views/projects/clusters/user/_show.html.haml
View file @
b3cdd336
...
...
@@ -9,7 +9,7 @@
-
if
@project
.
feature_available?
(
:multiple_clusters
)
=
field
.
text_field
:environment_scope
,
class:
'form-control js-select-on-focus'
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
-
else
=
field
.
text_field
:environment_scope
,
class:
'form-control js-select-on-focus'
,
disabled
:
true
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
=
field
.
text_field
:environment_scope
,
class:
'form-control js-select-on-focus'
,
readonly
:
true
,
placeholder:
s_
(
'ClusterIntegration|Environment scope'
)
=
field
.
fields_for
:platform_kubernetes
,
@cluster
.
platform_kubernetes
do
|
platform_kubernetes_field
|
.form-group
...
...
spec/ee/spec/features/projects/clusters_spec.rb
View file @
b3cdd336
...
...
@@ -10,49 +10,129 @@ feature 'EE Clusters' do
end
context
'when user has a cluster'
do
let!
(
:cluster
)
{
create
(
:cluster
,
:provided_by_gcp
,
projects:
[
project
])
}
context
'when license has multiple clusters feature'
do
before
do
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:multiple_clusters
).
and_return
(
true
)
end
context
'when user
visits clusters page
'
do
context
'when user
adds an existing cluster
'
do
before
do
create
(
:cluster
,
:provided_by_user
,
name:
'default-cluster'
,
environment_scope:
'*'
,
projects:
[
project
])
visit
project_clusters_path
(
project
)
end
it
'user sees a add cluster button '
do
expect
(
page
).
not_to
have_selector
(
'.js-add-cluster.
disabled
'
)
expect
(
page
).
not_to
have_selector
(
'.js-add-cluster.
readonly
'
)
expect
(
page
).
to
have_selector
(
'.js-add-cluster'
)
end
context
'when user tries to create a cluster with a duplicate environment scope'
do
context
'when user filled form with environment scope'
do
before
do
click_link
'Add cluster'
click_link
'Add an existing cluster'
fill_in
'cluster_name'
,
with:
'staging-cluster'
fill_in
'cluster_environment_scope'
,
with:
'staging/*'
click_button
'Add cluster'
end
it
'user sees a cluster details page'
do
expect
(
page
.
find_field
(
'cluster[name]'
).
value
).
to
eq
(
'staging-cluster'
)
expect
(
page
.
find_field
(
'cluster[environment_scope]'
).
value
).
to
eq
(
'staging/*'
)
end
end
context
'when user updates environment scope'
do
before
do
allow_any_instance_of
(
Projects
::
Clusters
::
GcpController
)
.
to
receive
(
:token_in_session
).
and_return
(
'token'
)
allow_any_instance_of
(
Projects
::
Clusters
::
GcpController
)
.
to
receive
(
:expires_at_in_session
).
and_return
(
1
.
hour
.
since
.
to_i
.
to_s
)
allow_any_instance_of
(
GoogleApi
::
CloudPlatform
::
Client
)
.
to
receive
(
:projects_zones_clusters_create
)
do
OpenStruct
.
new
(
self_link:
'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123'
,
status:
'RUNNING'
)
end
allow
(
WaitForClusterCreationWorker
).
to
receive
(
:perform_in
).
and_return
(
nil
)
click_link
'default-cluster'
fill_in
'cluster_environment_scope'
,
with:
'production/*'
click_button
'Save changes'
end
it
'user sees a cluster details page'
do
expect
(
page
.
find_field
(
'cluster[environment_scope]'
).
value
).
to
eq
(
'production/*'
)
end
end
context
'when user updates duplicated environment scope'
do
before
do
click_link
'Add cluster'
click_link
'Add an existing cluster'
fill_in
'cluster_name'
,
with:
'staging-cluster'
fill_in
'cluster_environment_scope'
,
with:
'*'
click_button
'Add cluster'
end
it
'users sees an environment scope validation error'
do
expect
(
page
).
to
have_content
(
'cannot add duplicated environment scope'
)
end
end
end
context
'when user adds an GKE cluster'
do
before
do
allow_any_instance_of
(
Projects
::
Clusters
::
GcpController
)
.
to
receive
(
:token_in_session
).
and_return
(
'token'
)
allow_any_instance_of
(
Projects
::
Clusters
::
GcpController
)
.
to
receive
(
:expires_at_in_session
).
and_return
(
1
.
hour
.
since
.
to_i
.
to_s
)
allow_any_instance_of
(
GoogleApi
::
CloudPlatform
::
Client
)
.
to
receive
(
:projects_zones_clusters_create
)
do
OpenStruct
.
new
(
self_link:
'projects/gcp-project-12345/zones/us-central1-a/operations/ope-123'
,
status:
'RUNNING'
)
end
allow
(
WaitForClusterCreationWorker
).
to
receive
(
:perform_in
).
and_return
(
nil
)
create
(
:cluster
,
:provided_by_gcp
,
name:
'default-cluster'
,
environment_scope:
'*'
,
projects:
[
project
])
visit
project_clusters_path
(
project
)
end
it
'user sees a add cluster button '
do
expect
(
page
).
not_to
have_selector
(
'.js-add-cluster.readonly'
)
expect
(
page
).
to
have_selector
(
'.js-add-cluster'
)
end
context
'when user filled form with environment scope'
do
before
do
click_link
'Add cluster'
click_link
'Create on GKE'
fill_in
'cluster_provider_gcp_attributes_gcp_project_id'
,
with:
'gcp-project-123'
fill_in
'cluster_name'
,
with:
'staging-cluster'
fill_in
'cluster_environment_scope'
,
with:
'staging/*'
click_button
'Create cluster'
end
it
'users sees an error'
do
it
'user sees a cluster details page'
do
expect
(
page
).
to
have_content
(
'Enable cluster integration'
)
expect
(
page
.
find_field
(
'cluster[environment_scope]'
).
value
).
to
eq
(
'staging/*'
)
end
end
context
'when user updates environment scope'
do
before
do
click_link
'default-cluster'
fill_in
'cluster_environment_scope'
,
with:
'production/*'
click_button
'Save changes'
end
it
'user sees a cluster details page'
do
expect
(
page
.
find_field
(
'cluster[environment_scope]'
).
value
).
to
eq
(
'production/*'
)
end
end
context
'when user updates duplicated environment scope'
do
before
do
click_link
'Add cluster'
click_link
'Create on GKE'
fill_in
'cluster_provider_gcp_attributes_gcp_project_id'
,
with:
'gcp-project-123'
fill_in
'cluster_name'
,
with:
'
dev
-cluster'
fill_in
'cluster_environment_scope'
,
with:
cluster
.
environment_scope
fill_in
'cluster_name'
,
with:
'
staging
-cluster'
fill_in
'cluster_environment_scope'
,
with:
'*'
click_button
'Create cluster'
expect
(
page
).
to
have_css
(
'#error_explanation'
)
end
it
'users sees an environment scope validation error'
do
expect
(
page
).
to
have_content
(
'cannot add duplicated environment scope'
)
end
end
end
...
...
@@ -62,6 +142,7 @@ feature 'EE Clusters' do
before
do
allow
(
License
).
to
receive
(
:feature_available?
).
and_call_original
allow
(
License
).
to
receive
(
:feature_available?
).
with
(
:multiple_clusters
).
and_return
(
false
)
create
(
:cluster
,
:provided_by_user
,
name:
'default-cluster'
,
environment_scope:
'*'
,
projects:
[
project
])
end
context
'when user visits cluster index page'
do
...
...
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