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
6712762b
Commit
6712762b
authored
Oct 06, 2017
by
Shinya Maeda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add ClusterPresenter. Fix Static Analysys.
parent
d27b113b
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
56 additions
and
13 deletions
+56
-13
app/controllers/projects/clusters_controller.rb
app/controllers/projects/clusters_controller.rb
+1
-1
app/models/gcp/cluster.rb
app/models/gcp/cluster.rb
+1
-0
app/presenters/gcp/cluster_presenter.rb
app/presenters/gcp/cluster_presenter.rb
+9
-0
app/views/projects/clusters/show.html.haml
app/views/projects/clusters/show.html.haml
+1
-1
spec/controllers/projects/clusters_controller_spec.rb
spec/controllers/projects/clusters_controller_spec.rb
+9
-11
spec/presenters/gcp/cluster_presenter_spec.rb
spec/presenters/gcp/cluster_presenter_spec.rb
+35
-0
No files found.
app/controllers/projects/clusters_controller.rb
View file @
6712762b
...
...
@@ -81,7 +81,7 @@ class Projects::ClustersController < Projects::ApplicationController
private
def
cluster
@cluster
||=
project
.
cluster
@cluster
||=
project
.
cluster
.
present
(
current_user:
current_user
)
end
def
create_params
...
...
app/models/gcp/cluster.rb
View file @
6712762b
module
Gcp
class
Cluster
<
ActiveRecord
::
Base
extend
Gitlab
::
Gcp
::
Model
include
Presentable
belongs_to
:project
,
inverse_of: :cluster
belongs_to
:user
...
...
app/presenters/gcp/cluster_presenter.rb
0 → 100644
View file @
6712762b
module
Gcp
class
ClusterPresenter
<
Gitlab
::
View
::
Presenter
::
Delegated
presents
:cluster
def
gke_cluster_url
"https://console.cloud.google.com/kubernetes/clusters/details/
#{
gcp_cluster_zone
}
/
#{
gcp_cluster_name
}
"
end
end
end
app/views/projects/clusters/show.html.haml
View file @
6712762b
...
...
@@ -37,7 +37,7 @@
%label
=
s_
(
'ClusterIntegration|Google container engine'
)
%p
-
link_gke
=
link_to
(
s_
(
'ClusterIntegration|Google Container Engine'
),
''
,
target:
'_blank'
,
rel:
'noopener noreferrer'
)
-
link_gke
=
link_to
(
s_
(
'ClusterIntegration|Google Container Engine'
),
@cluster
.
gke_cluster_url
,
target:
'_blank'
,
rel:
'noopener noreferrer'
)
=
s_
(
'ClusterIntegration|Manage your cluster by visiting %{link_gke}'
).
html_safe
%
{
link_gke:
link_gke
}
.hidden.js-cluster-error.alert.alert-danger
{
role:
'alert'
}
...
...
spec/controllers/projects/clusters_controller_spec.rb
View file @
6712762b
...
...
@@ -100,8 +100,7 @@ describe Projects::ClustersController do
describe
'POST create'
do
subject
do
post
:create
,
params
.
merge
(
namespace_id:
project
.
namespace
,
post
:create
,
params
.
merge
(
namespace_id:
project
.
namespace
,
project_id:
project
)
end
...
...
@@ -121,7 +120,7 @@ describe Projects::ClustersController do
{
cluster:
{
gcp_cluster_name:
'new-cluster'
,
gcp_project_id:
'111'
,
gcp_project_id:
'111'
}
}
end
...
...
@@ -221,8 +220,7 @@ describe Projects::ClustersController do
let
(
:params
)
{
{}
}
subject
do
put
:update
,
params
.
merge
(
namespace_id:
project
.
namespace
,
put
:update
,
params
.
merge
(
namespace_id:
project
.
namespace
,
project_id:
project
,
id:
cluster
)
end
...
...
spec/presenters/gcp/cluster_presenter_spec.rb
0 → 100644
View file @
6712762b
require
'spec_helper'
describe
Gcp
::
ClusterPresenter
do
let
(
:project
)
{
create
(
:project
)
}
let
(
:cluster
)
{
create
(
:gcp_cluster
,
project:
project
)
}
subject
(
:presenter
)
do
described_class
.
new
(
cluster
)
end
it
'inherits from Gitlab::View::Presenter::Delegated'
do
expect
(
described_class
.
superclass
).
to
eq
(
Gitlab
::
View
::
Presenter
::
Delegated
)
end
describe
'#initialize'
do
it
'takes a cluster and optional params'
do
expect
{
presenter
}.
not_to
raise_error
end
it
'exposes cluster'
do
expect
(
presenter
.
cluster
).
to
eq
(
cluster
)
end
it
'forwards missing methods to cluster'
do
expect
(
presenter
.
gcp_cluster_zone
).
to
eq
(
cluster
.
gcp_cluster_zone
)
end
end
describe
'#gke_cluster_url'
do
subject
{
described_class
.
new
(
cluster
).
gke_cluster_url
}
it
{
is_expected
.
to
include
(
cluster
.
gcp_cluster_zone
)
}
it
{
is_expected
.
to
include
(
cluster
.
gcp_cluster_name
)
}
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