debian-mirror-gitlab/spec/helpers/sourcegraph_helper_spec.rb

48 lines
1.7 KiB
Ruby
Raw Normal View History

2019-12-26 22:10:19 +05:30
# frozen_string_literal: true
require 'spec_helper'
2020-07-28 23:09:34 +05:30
RSpec.describe SourcegraphHelper do
2019-12-26 22:10:19 +05:30
describe '#sourcegraph_url_message' do
let(:sourcegraph_url) { 'http://sourcegraph.example.com' }
2021-01-29 00:20:46 +05:30
let(:feature_conditional) { false }
let(:public_only) { false }
let(:is_com) { true }
2019-12-26 22:10:19 +05:30
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)
2021-01-29 00:20:46 +05:30
allow(Gitlab::CurrentSettings).to receive(:sourcegraph_public_only).and_return(public_only)
allow(Gitlab::Sourcegraph).to receive(:feature_conditional?).and_return(feature_conditional)
2019-12-26 22:10:19 +05:30
end
subject { helper.sourcegraph_url_message }
context 'with .com sourcegraph url' do
2021-01-29 00:20:46 +05:30
it { is_expected.to have_text('Uses %{linkStart}Sourcegraph.com%{linkEnd}. This feature is experimental.') }
2019-12-26 22:10:19 +05:30
end
context 'with custom sourcegraph url' do
let(:is_com) { false }
2021-01-29 00:20:46 +05:30
it { is_expected.to have_text('Uses a custom %{linkStart}Sourcegraph instance%{linkEnd}. This feature is experimental.') }
2019-12-26 22:10:19 +05:30
end
context 'when not limited by feature or public only' do
2021-01-29 00:20:46 +05:30
it { is_expected.to eq 'Uses %{linkStart}Sourcegraph.com%{linkEnd}. This feature is experimental.' }
2019-12-26 22:10:19 +05:30
end
context 'when limited by feature' do
let(:feature_conditional) { true }
2021-01-29 00:20:46 +05:30
it { is_expected.to eq 'Uses %{linkStart}Sourcegraph.com%{linkEnd}. This feature is experimental and currently limited to certain projects.' }
2019-12-26 22:10:19 +05:30
end
context 'when limited by public only' do
let(:public_only) { true }
2021-01-29 00:20:46 +05:30
it { is_expected.to eq 'Uses %{linkStart}Sourcegraph.com%{linkEnd}. This feature is experimental and limited to public projects.' }
2019-12-26 22:10:19 +05:30
end
end
end