diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-15 21:06:24 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2019-11-15 21:06:24 +0300 |
commit | eca3cd3a9e7d9ea680086cad8150050ec8cdef3f (patch) | |
tree | c3d262e0d8e721fc138c2d617f501fb09876f1b6 /spec/models/application_setting_spec.rb | |
parent | 6e81d7f6283fae1b22f66b9d9b133243921cbd9e (diff) |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'spec/models/application_setting_spec.rb')
-rw-r--r-- | spec/models/application_setting_spec.rb | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/spec/models/application_setting_spec.rb b/spec/models/application_setting_spec.rb index 4aa8f2d959d..ba3b99f4421 100644 --- a/spec/models/application_setting_spec.rb +++ b/spec/models/application_setting_spec.rb @@ -3,6 +3,8 @@ require 'spec_helper' describe ApplicationSetting do + using RSpec::Parameterized::TableSyntax + subject(:setting) { described_class.create_from_defaults } it { include(CacheableAttributes) } @@ -495,6 +497,15 @@ describe ApplicationSetting do it { is_expected.not_to allow_value(nil).for(:static_objects_external_storage_auth_token) } end end + + context 'sourcegraph settings' do + it 'is invalid if sourcegraph is enabled and no url is provided' do + allow(subject).to receive(:sourcegraph_enabled).and_return(true) + + expect(subject.sourcegraph_url).to be_nil + is_expected.to be_invalid + end + end end context 'restrict creating duplicates' do @@ -583,5 +594,24 @@ describe ApplicationSetting do end end + describe '#sourcegraph_url_is_com?' do + where(:url, :is_com) do + 'https://sourcegraph.com' | true + 'https://sourcegraph.com/' | true + 'https://www.sourcegraph.com' | true + 'shttps://www.sourcegraph.com' | false + 'https://sourcegraph.example.com/' | false + 'https://sourcegraph.org/' | false + end + + with_them do + it 'matches the url with sourcegraph.com' do + setting.sourcegraph_url = url + + expect(setting.sourcegraph_url_is_com?).to eq(is_com) + end + end + end + it_behaves_like 'application settings examples' end |