From 7e9c479f7de77702622631cff2628a9c8dcbc627 Mon Sep 17 00:00:00 2001 From: GitLab Bot Date: Thu, 19 Nov 2020 08:27:35 +0000 Subject: Add latest changes from gitlab-org/gitlab@13-6-stable-ee --- spec/helpers/sourcegraph_helper_spec.rb | 37 +++++++++------------------------ 1 file changed, 10 insertions(+), 27 deletions(-) (limited to 'spec/helpers/sourcegraph_helper_spec.rb') diff --git a/spec/helpers/sourcegraph_helper_spec.rb b/spec/helpers/sourcegraph_helper_spec.rb index 6a95c8e4a43..d03893ea9ae 100644 --- a/spec/helpers/sourcegraph_helper_spec.rb +++ b/spec/helpers/sourcegraph_helper_spec.rb @@ -5,60 +5,43 @@ require 'spec_helper' RSpec.describe SourcegraphHelper do describe '#sourcegraph_url_message' do let(:sourcegraph_url) { 'http://sourcegraph.example.com' } + let(:feature_conditional) { false } + let(:public_only) { false } + let(:is_com) { true } before do allow(Gitlab::CurrentSettings).to receive(:sourcegraph_url).and_return(sourcegraph_url) allow(Gitlab::CurrentSettings).to receive(:sourcegraph_url_is_com?).and_return(is_com) + allow(Gitlab::CurrentSettings).to receive(:sourcegraph_public_only).and_return(public_only) + allow(Gitlab::Sourcegraph).to receive(:feature_conditional?).and_return(feature_conditional) end subject { helper.sourcegraph_url_message } context 'with .com sourcegraph url' do - let(:is_com) { true } - - it { is_expected.to have_text('Uses Sourcegraph.com') } - it { is_expected.to have_link('Sourcegraph.com', href: sourcegraph_url) } + it { is_expected.to have_text('Uses %{linkStart}Sourcegraph.com%{linkEnd}. This feature is experimental.') } end context 'with custom sourcegraph url' do let(:is_com) { false } - it { is_expected.to have_text('Uses a custom Sourcegraph instance') } - it { is_expected.to have_link('Sourcegraph instance', href: sourcegraph_url) } - - context 'with unsafe url' do - let(:sourcegraph_url) { '\" onload=\"alert(1);\"' } - - it { is_expected.to have_link('Sourcegraph instance', href: sourcegraph_url) } - end + it { is_expected.to have_text('Uses a custom %{linkStart}Sourcegraph instance%{linkEnd}. This feature is experimental.') } end - end - - describe '#sourcegraph_experimental_message' do - let(:feature_conditional) { false } - let(:public_only) { false } - - before do - allow(Gitlab::CurrentSettings).to receive(:sourcegraph_public_only).and_return(public_only) - allow(Gitlab::Sourcegraph).to receive(:feature_conditional?).and_return(feature_conditional) - end - - subject { helper.sourcegraph_experimental_message } context 'when not limited by feature or public only' do - it { is_expected.to eq "This feature is experimental." } + it { is_expected.to eq 'Uses %{linkStart}Sourcegraph.com%{linkEnd}. This feature is experimental.' } end context 'when limited by feature' do let(:feature_conditional) { true } - it { is_expected.to eq "This feature is experimental and currently limited to certain projects." } + it { is_expected.to eq 'Uses %{linkStart}Sourcegraph.com%{linkEnd}. This feature is experimental and currently limited to certain projects.' } end context 'when limited by public only' do let(:public_only) { true } - it { is_expected.to eq "This feature is experimental and limited to public projects." } + it { is_expected.to eq 'Uses %{linkStart}Sourcegraph.com%{linkEnd}. This feature is experimental and limited to public projects.' } end end end -- cgit v1.2.3