summaryrefslogtreecommitdiff
path: root/spec/presenters
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2021-10-20 08:43:02 +0000
committerGitLab Bot <gitlab-bot@gitlab.com>2021-10-20 08:43:02 +0000
commitd9ab72d6080f594d0b3cae15f14b3ef2c6c638cb (patch)
tree2341ef426af70ad1e289c38036737e04b0aa5007 /spec/presenters
parentd6e514dd13db8947884cd58fe2a9c2a063400a9b (diff)
downloadgitlab-ce-d9ab72d6080f594d0b3cae15f14b3ef2c6c638cb.tar.gz
Add latest changes from gitlab-org/gitlab@14-4-stable-eev14.4.0-rc42
Diffstat (limited to 'spec/presenters')
-rw-r--r--spec/presenters/clusters/cluster_presenter_spec.rb143
-rw-r--r--spec/presenters/commit_status_presenter_spec.rb19
-rw-r--r--spec/presenters/group_clusterable_presenter_spec.rb6
-rw-r--r--spec/presenters/instance_clusterable_presenter_spec.rb6
-rw-r--r--spec/presenters/project_clusterable_presenter_spec.rb6
5 files changed, 37 insertions, 143 deletions
diff --git a/spec/presenters/clusters/cluster_presenter_spec.rb b/spec/presenters/clusters/cluster_presenter_spec.rb
index c8da8a54f16..49126ed8e5f 100644
--- a/spec/presenters/clusters/cluster_presenter_spec.rb
+++ b/spec/presenters/clusters/cluster_presenter_spec.rb
@@ -30,129 +30,6 @@ RSpec.describe Clusters::ClusterPresenter do
end
end
- describe '#item_link' do
- let(:clusterable_presenter) { double('ClusterablePresenter', subject: clusterable) }
-
- subject { presenter.item_link(clusterable_presenter) }
-
- context 'for a group cluster' do
- let(:cluster) { create(:cluster, cluster_type: :group_type, groups: [group]) }
- let(:group) { create(:group, name: 'Foo') }
- let(:cluster_link) { "<a href=\"#{group_cluster_path(cluster.group, cluster)}\">#{cluster.name}</a>" }
-
- before do
- group.add_maintainer(user)
- end
-
- shared_examples 'ancestor clusters' do
- context 'ancestor clusters' do
- let(:root_group) { create(:group, name: 'Root Group') }
- let(:parent) { create(:group, name: 'parent', parent: root_group) }
- let(:child) { create(:group, name: 'child', parent: parent) }
- let(:group) { create(:group, name: 'group', parent: child) }
-
- before do
- root_group.add_maintainer(user)
- end
-
- context 'top level group cluster' do
- let(:cluster) { create(:cluster, cluster_type: :group_type, groups: [root_group]) }
-
- it 'returns full group names and link for cluster' do
- expect(subject).to eq("Root Group / #{cluster_link}")
- end
-
- it 'is html safe' do
- expect(presenter).to receive(:sanitize).with('Root Group').and_call_original
-
- expect(subject).to be_html_safe
- end
- end
-
- context 'first level group cluster' do
- let(:cluster) { create(:cluster, cluster_type: :group_type, groups: [parent]) }
-
- it 'returns full group names and link for cluster' do
- expect(subject).to eq("Root Group / parent / #{cluster_link}")
- end
-
- it 'is html safe' do
- expect(presenter).to receive(:sanitize).with('Root Group / parent').and_call_original
-
- expect(subject).to be_html_safe
- end
- end
-
- context 'second level group cluster' do
- let(:cluster) { create(:cluster, cluster_type: :group_type, groups: [child]) }
-
- let(:ellipsis_h) do
- /.*ellipsis_h.*/
- end
-
- it 'returns clipped group names and link for cluster' do
- expect(subject).to match("Root Group / #{ellipsis_h} / child / #{cluster_link}")
- end
-
- it 'is html safe' do
- expect(presenter).to receive(:sanitize).with('Root Group / parent / child').and_call_original
-
- expect(subject).to be_html_safe
- end
- end
- end
- end
-
- context 'for a project clusterable' do
- let(:clusterable) { project }
- let(:project) { create(:project, group: group) }
-
- it 'returns the group name and the link for cluster' do
- expect(subject).to eq("Foo / #{cluster_link}")
- end
-
- it 'is html safe' do
- expect(presenter).to receive(:sanitize).with('Foo').and_call_original
-
- expect(subject).to be_html_safe
- end
-
- include_examples 'ancestor clusters'
- end
-
- context 'for the group clusterable for the cluster' do
- let(:clusterable) { group }
-
- it 'returns link for cluster' do
- expect(subject).to eq(cluster_link)
- end
-
- include_examples 'ancestor clusters'
-
- it 'is html safe' do
- expect(subject).to be_html_safe
- end
- end
- end
-
- context 'for a project cluster' do
- let(:cluster) { create(:cluster, :project) }
- let(:cluster_link) { "<a href=\"#{project_cluster_path(cluster.project, cluster)}\">#{cluster.name}</a>" }
-
- before do
- cluster.project.add_maintainer(user)
- end
-
- context 'for the project clusterable' do
- let(:clusterable) { cluster.project }
-
- it 'returns link for cluster' do
- expect(subject).to eq(cluster_link)
- end
- end
- end
- end
-
describe '#provider_label' do
let(:cluster) { create(:cluster, provider_type: provider_type) }
@@ -191,26 +68,6 @@ RSpec.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
-
- context 'instance_type cluster' do
- let(:cluster) { create(:cluster, :provided_by_gcp, :instance) }
-
- it { is_expected.to eq('Instance cluster') }
- end
- end
-
describe '#show_path' do
subject { described_class.new(cluster).show_path }
diff --git a/spec/presenters/commit_status_presenter_spec.rb b/spec/presenters/commit_status_presenter_spec.rb
index 4b2441d656e..f0bf1b860e4 100644
--- a/spec/presenters/commit_status_presenter_spec.rb
+++ b/spec/presenters/commit_status_presenter_spec.rb
@@ -15,6 +15,25 @@ RSpec.describe CommitStatusPresenter do
expect(described_class.superclass).to eq(Gitlab::View::Presenter::Delegated)
end
+ describe '#callout_failure_message' do
+ subject { presenter.callout_failure_message }
+
+ context 'when troubleshooting doc is available' do
+ let(:failure_reason) { :environment_creation_failure }
+
+ before do
+ build.failure_reason = failure_reason
+ end
+
+ it 'appends the troubleshooting link' do
+ doc = described_class::TROUBLESHOOTING_DOC[failure_reason]
+
+ expect(subject).to eq("#{described_class.callout_failure_messages[failure_reason]} " \
+ "<a href=\"#{presenter.help_page_path(doc[:path], anchor: doc[:anchor])}\">How do I fix it?</a>")
+ end
+ end
+ end
+
describe 'covers all failure reasons' do
let(:message) { presenter.callout_failure_message }
diff --git a/spec/presenters/group_clusterable_presenter_spec.rb b/spec/presenters/group_clusterable_presenter_spec.rb
index 84b97ba0bb7..b2dff2e3546 100644
--- a/spec/presenters/group_clusterable_presenter_spec.rb
+++ b/spec/presenters/group_clusterable_presenter_spec.rb
@@ -84,4 +84,10 @@ RSpec.describe GroupClusterablePresenter do
it { is_expected.to eq(metrics_dashboard_group_cluster_path(group, cluster)) }
end
+
+ describe '#learn_more_link' do
+ subject { presenter.learn_more_link }
+
+ it { is_expected.to include('user/group/clusters/index') }
+ end
end
diff --git a/spec/presenters/instance_clusterable_presenter_spec.rb b/spec/presenters/instance_clusterable_presenter_spec.rb
index 6968e3a4da3..0ace57bbf4d 100644
--- a/spec/presenters/instance_clusterable_presenter_spec.rb
+++ b/spec/presenters/instance_clusterable_presenter_spec.rb
@@ -32,4 +32,10 @@ RSpec.describe InstanceClusterablePresenter do
it { is_expected.to eq(metrics_dashboard_admin_cluster_path(cluster)) }
end
+
+ describe '#learn_more_link' do
+ subject { presenter.learn_more_link }
+
+ it { is_expected.to include('user/instance/clusters/index') }
+ end
end
diff --git a/spec/presenters/project_clusterable_presenter_spec.rb b/spec/presenters/project_clusterable_presenter_spec.rb
index 9057b518647..90b6671edd3 100644
--- a/spec/presenters/project_clusterable_presenter_spec.rb
+++ b/spec/presenters/project_clusterable_presenter_spec.rb
@@ -84,4 +84,10 @@ RSpec.describe ProjectClusterablePresenter do
it { is_expected.to eq(metrics_dashboard_project_cluster_path(project, cluster)) }
end
+
+ describe '#learn_more_link' do
+ subject { presenter.learn_more_link }
+
+ it { is_expected.to include('user/project/clusters/index') }
+ end
end