From 8af3b4e0752ad83fd44ea2bce7fdce3478221a45 Mon Sep 17 00:00:00 2001 From: Gabriel Mazetto Date: Wed, 13 Mar 2019 18:23:06 +0100 Subject: [PATCH] Only display Geo button when in a Geo secondary node This shared view is used by the Wiki clone screen and also by GitLab when in mobile version. --- app/views/shared/_clone_panel.html.haml | 2 +- ...-geo-clone-button-should-check-for-geo.yml | 6 +++ .../shared/_clone_panel.html.haml_spec.rb | 43 +++++++++++++++++++ 3 files changed, 50 insertions(+), 1 deletion(-) create mode 100644 ee/changelogs/unreleased/10398-geo-clone-button-should-check-for-geo.yml create mode 100644 spec/views/shared/_clone_panel.html.haml_spec.rb diff --git a/app/views/shared/_clone_panel.html.haml b/app/views/shared/_clone_panel.html.haml index 16ad8ebc65675f..40e76468a243d7 100644 --- a/app/views/shared/_clone_panel.html.haml +++ b/app/views/shared/_clone_panel.html.haml @@ -24,6 +24,6 @@ .input-group-append = clipboard_button(target: '#project_clone', title: _("Copy URL to clipboard"), class: "input-group-text btn-default btn-clipboard") - = geo_button(modal_target: '#modal-geo-info') + = geo_button(modal_target: '#modal-geo-info') if Gitlab::Geo.secondary? = render 'shared/geo_info_modal', project: project if Gitlab::Geo.secondary? diff --git a/ee/changelogs/unreleased/10398-geo-clone-button-should-check-for-geo.yml b/ee/changelogs/unreleased/10398-geo-clone-button-should-check-for-geo.yml new file mode 100644 index 00000000000000..f67b8d6f217ee1 --- /dev/null +++ b/ee/changelogs/unreleased/10398-geo-clone-button-should-check-for-geo.yml @@ -0,0 +1,6 @@ +--- +title: 'Geo: Only display Geo-specific clone instructions button on a Geo Secondary + node' +merge_request: 10007 +author: +type: fixed diff --git a/spec/views/shared/_clone_panel.html.haml_spec.rb b/spec/views/shared/_clone_panel.html.haml_spec.rb new file mode 100644 index 00000000000000..28f8fb70edbd67 --- /dev/null +++ b/spec/views/shared/_clone_panel.html.haml_spec.rb @@ -0,0 +1,43 @@ +# frozen_string_literal: true + +require 'spec_helper' + +describe 'shared/_clone_panel' do + include EE::GeoHelpers + + set(:primary) { create(:geo_node, :primary) } + set(:secondary) { create(:geo_node) } + set(:project) { create(:project) } + + shared_examples 'has no geo-specific instructions' do + it 'has no geo-specific instructions' do + render 'shared/clone_panel', project: project + + expect(rendered).not_to match /See Geo-specific instructions/ + end + end + + context 'without Geo enabled' do + it_behaves_like 'has no geo-specific instructions' + end + + context 'On a Geo primary node' do + before do + stub_current_geo_node(primary) + end + + it_behaves_like 'has no geo-specific instructions' + end + + context 'On a Geo secondary node' do + before do + stub_current_geo_node(secondary) + end + + it 'renders Geo-specific instructions button' do + render 'shared/clone_panel', project: project + + expect(rendered).to match /See Geo-specific instructions/ + end + end +end -- GitLab