summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2018-12-14 15:36:31 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2018-12-14 15:36:31 +0000
commit4ee1eb38f07fa9ea6ac31e68eedc0c60ab93c29b (patch)
tree2f0e814cffe3f40252e5539086c856bd3b3890bd
parenta0fd68288d3f8f57d1c65423f08fc6a99824de1d (diff)
parent459758921faefa10c475c4691faa4d388eb00df8 (diff)
downloadgitlab-ce-4ee1eb38f07fa9ea6ac31e68eedc0c60ab93c29b.tar.gz
Merge branch '53771-move-cluster-type-description' into 'master'
Move description of cluster type to presenter Closes #53771 See merge request gitlab-org/gitlab-ce!23789
-rw-r--r--app/presenters/clusters/cluster_presenter.rb8
-rw-r--r--app/views/clusters/clusters/_cluster.html.haml2
-rw-r--r--spec/presenters/clusters/cluster_presenter_spec.rb14
3 files changed, 23 insertions, 1 deletions
diff --git a/app/presenters/clusters/cluster_presenter.rb b/app/presenters/clusters/cluster_presenter.rb
index 7e6eccb648c..0473bb8c72a 100644
--- a/app/presenters/clusters/cluster_presenter.rb
+++ b/app/presenters/clusters/cluster_presenter.rb
@@ -12,6 +12,14 @@ module Clusters
can?(current_user, :update_cluster, cluster) && created?
end
+ def cluster_type_description
+ if cluster.project_type?
+ s_("ClusterIntegration|Project cluster")
+ elsif cluster.group_type?
+ s_("ClusterIntegration|Group cluster")
+ end
+ end
+
def show_path
if cluster.project_type?
project_cluster_path(project, cluster)
diff --git a/app/views/clusters/clusters/_cluster.html.haml b/app/views/clusters/clusters/_cluster.html.haml
index adeca013749..e15de3d504d 100644
--- a/app/views/clusters/clusters/_cluster.html.haml
+++ b/app/views/clusters/clusters/_cluster.html.haml
@@ -13,4 +13,4 @@
.table-mobile-header{ role: "rowheader" }
.table-mobile-content
%span.badge.badge-light
- = cluster.project_type? ? s_("ClusterIntegration|Project cluster") : s_("ClusterIntegration|Group cluster")
+ = cluster.cluster_type_description
diff --git a/spec/presenters/clusters/cluster_presenter_spec.rb b/spec/presenters/clusters/cluster_presenter_spec.rb
index 72c5eac3ede..63c2ff26a45 100644
--- a/spec/presenters/clusters/cluster_presenter_spec.rb
+++ b/spec/presenters/clusters/cluster_presenter_spec.rb
@@ -74,6 +74,20 @@ describe Clusters::ClusterPresenter do
end
end
+ describe '#cluster_type_description' do
+ subject { described_class.new(cluster).cluster_type_description }
+
+ context 'project_type cluster' do
+ it { is_expected.to eq('Project cluster') }
+ end
+
+ context 'group_type cluster' do
+ let(:cluster) { create(:cluster, :provided_by_gcp, :group) }
+
+ it { is_expected.to eq('Group cluster') }
+ end
+ end
+
describe '#show_path' do
subject { described_class.new(cluster).show_path }