Expose instance AutoDevOps domain in Project

This commit is contained in:
Matija Čupić 2018-01-22 19:31:35 +01:00
parent 5706029503
commit 8f0a14843a
No known key found for this signature in database
GPG Key ID: 4BAF84FFACD2E5DE
2 changed files with 40 additions and 6 deletions

View File

@ -1604,7 +1604,15 @@ class Project < ActiveRecord::Base
def auto_devops_variables def auto_devops_variables
return [] unless auto_devops_enabled? 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 end
def append_or_update_attribute(name, value) def append_or_update_attribute(name, value)

View File

@ -2976,18 +2976,40 @@ describe Project do
subject { project.auto_devops_variables } subject { project.auto_devops_variables }
context 'when enabled in settings' do context 'when enabled in instance settings' do
before do before do
stub_application_setting(auto_devops_enabled: true) stub_application_setting(auto_devops_enabled: true)
end 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 context 'when domain is empty' do
before do before do
create(:project_auto_devops, project: project, domain: nil) create(:project_auto_devops, project: project, domain: nil)
end end
it 'variables are empty' do it 'variables does not include AUTO_DEVOPS_DOMAIN' do
is_expected.to be_empty is_expected.not_to include(domain_variable)
end end
end end
@ -2996,11 +3018,15 @@ describe Project do
create(:project_auto_devops, project: project, domain: 'example.com') create(:project_auto_devops, project: project, domain: 'example.com')
end end
it "variables are not empty" do it 'variables includes AUTO_DEVOPS_DOMAIN' do
is_expected.not_to be_empty is_expected.to include(domain_variable)
end end
end end
end end
def domain_variable
{ key: 'AUTO_DEVOPS_DOMAIN', value: 'example.com', public: true }
end
end end
describe '#latest_successful_builds_for' do describe '#latest_successful_builds_for' do