summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authorShinya Maeda <shinya@gitlab.com>2017-10-06 02:45:15 +0900
committerShinya Maeda <shinya@gitlab.com>2017-10-06 02:45:15 +0900
commit6712762b9d6e0391b1a38ca17cc3d982a336bbf9 (patch)
treebbb3b008409a18aca0bbd86480ac4b52eb33668e /spec
parentd27b113b49c90ba7d184f0d7965b63e32d260ebf (diff)
downloadgitlab-ce-6712762b9d6e0391b1a38ca17cc3d982a336bbf9.tar.gz
Add ClusterPresenter. Fix Static Analysys.
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/projects/clusters_controller_spec.rb20
-rw-r--r--spec/presenters/gcp/cluster_presenter_spec.rb35
2 files changed, 44 insertions, 11 deletions
diff --git a/spec/controllers/projects/clusters_controller_spec.rb b/spec/controllers/projects/clusters_controller_spec.rb
index af182a20f14..604b92caca6 100644
--- a/spec/controllers/projects/clusters_controller_spec.rb
+++ b/spec/controllers/projects/clusters_controller_spec.rb
@@ -100,9 +100,8 @@ describe Projects::ClustersController do
describe 'POST create' do
subject do
- post :create, params.merge(
- namespace_id: project.namespace,
- project_id: project)
+ post :create, params.merge(namespace_id: project.namespace,
+ project_id: project)
end
context 'when not logged' do
@@ -117,12 +116,12 @@ describe Projects::ClustersController do
end
context 'when all required parameters are set' do
- let(:params) do
+ let(:params) do
{
cluster: {
gcp_cluster_name: 'new-cluster',
- gcp_project_id: '111',
- }
+ gcp_project_id: '111'
+ }
}
end
@@ -140,7 +139,7 @@ describe Projects::ClustersController do
context 'when not all required parameters are set' do
render_views
- let(:params) do
+ let(:params) do
{
cluster: {
project_namespace: 'some namespace'
@@ -221,10 +220,9 @@ describe Projects::ClustersController do
let(:params) { {} }
subject do
- put :update, params.merge(
- namespace_id: project.namespace,
- project_id: project,
- id: cluster)
+ put :update, params.merge(namespace_id: project.namespace,
+ project_id: project,
+ id: cluster)
end
context 'when logged as master' do
diff --git a/spec/presenters/gcp/cluster_presenter_spec.rb b/spec/presenters/gcp/cluster_presenter_spec.rb
new file mode 100644
index 00000000000..8d86dc31582
--- /dev/null
+++ b/spec/presenters/gcp/cluster_presenter_spec.rb
@@ -0,0 +1,35 @@
+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