summaryrefslogtreecommitdiff
path: root/spec/models/project_auto_devops_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/project_auto_devops_spec.rb')
-rw-r--r--spec/models/project_auto_devops_spec.rb43
1 files changed, 40 insertions, 3 deletions
diff --git a/spec/models/project_auto_devops_spec.rb b/spec/models/project_auto_devops_spec.rb
index 12069575866..296b91a771c 100644
--- a/spec/models/project_auto_devops_spec.rb
+++ b/spec/models/project_auto_devops_spec.rb
@@ -18,7 +18,21 @@ describe ProjectAutoDevops do
context 'when domain is empty' do
let(:auto_devops) { build_stubbed(:project_auto_devops, project: project, domain: '') }
- it { expect(auto_devops).not_to have_domain }
+ context 'when there is an instance domain specified' do
+ before do
+ allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return('example.com')
+ end
+
+ it { expect(auto_devops).to have_domain }
+ end
+
+ context 'when there is no instance domain specified' do
+ before do
+ allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return(nil)
+ end
+
+ it { expect(auto_devops).not_to have_domain }
+ end
end
end
@@ -29,9 +43,32 @@ describe ProjectAutoDevops do
let(:domain) { 'example.com' }
it 'returns AUTO_DEVOPS_DOMAIN' do
- expect(auto_devops.variables).to include(
- { key: 'AUTO_DEVOPS_DOMAIN', value: 'example.com', public: true })
+ expect(auto_devops.variables).to include(domain_variable)
end
end
+
+ context 'when domain is not defined' do
+ let(:domain) { nil }
+
+ context 'when there is an instance domain specified' do
+ before do
+ allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return('example.com')
+ end
+
+ it { expect(auto_devops.variables).to include(domain_variable) }
+ end
+
+ context 'when there is no instance domain specified' do
+ before do
+ allow(Gitlab::CurrentSettings).to receive(:auto_devops_domain).and_return(nil)
+ end
+
+ it { expect(auto_devops.variables).not_to include(domain_variable) }
+ end
+ end
+
+ def domain_variable
+ { key: 'AUTO_DEVOPS_DOMAIN', value: 'example.com', public: true }
+ end
end
end