Commit 8f0a1484 authored by Matija Čupić's avatar Matija Čupić

Expose instance AutoDevOps domain in Project

parent 57060295
......@@ -1604,7 +1604,15 @@ class Project < ActiveRecord::Base
def auto_devops_variables
return [] unless auto_devops_enabled?
auto_devops&.variables || []
variables = []
if current_application_settings.auto_devops_domain.present?
variables << { key: 'AUTO_DEVOPS_DOMAIN',
value: current_application_settings.auto_devops_domain,
public: true }
end
auto_devops&.variables || variables
end
def append_or_update_attribute(name, value)
......
......@@ -2976,18 +2976,40 @@ describe Project do
subject { project.auto_devops_variables }
context 'when enabled in settings' do
context 'when enabled in instance settings' do
before do
stub_application_setting(auto_devops_enabled: true)
end
context 'when domain is empty' do
before do
stub_application_setting(auto_devops_domain: nil)
end
it 'variables does not include AUTO_DEVOPS_DOMAIN' do
is_expected.not_to include(domain_variable)
end
end
context 'when domain is configured' do
before do
stub_application_setting(auto_devops_domain: 'example.com')
end
it 'variables includes AUTO_DEVOPS_DOMAIN' do
is_expected.to include(domain_variable)
end
end
end
context 'when explicitely enabled' do
context 'when domain is empty' do
before do
create(:project_auto_devops, project: project, domain: nil)
end
it 'variables are empty' do
is_expected.to be_empty
it 'variables does not include AUTO_DEVOPS_DOMAIN' do
is_expected.not_to include(domain_variable)
end
end
......@@ -2996,11 +3018,15 @@ describe Project do
create(:project_auto_devops, project: project, domain: 'example.com')
end
it "variables are not empty" do
is_expected.not_to be_empty
it 'variables includes AUTO_DEVOPS_DOMAIN' do
is_expected.to include(domain_variable)
end
end
end
def domain_variable
{ key: 'AUTO_DEVOPS_DOMAIN', value: 'example.com', public: true }
end
end
describe '#latest_successful_builds_for' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment