Commit a3153984 authored by Matija Čupić's avatar Matija Čupić

Add specs for .auto_devops_warning_message

parent 5126b1c5
...@@ -9,21 +9,28 @@ module AutoDevopsHelper ...@@ -9,21 +9,28 @@ module AutoDevopsHelper
end end
def auto_devops_warning_message(project) def auto_devops_warning_message(project)
missing_domain = !project.auto_devops&.has_domain? if missing_service?
missing_service = !project.deployment_platform&.active?
if missing_service
params = { params = {
kubernetes: link_to('Kubernetes cluster', project_clusters_path(project)) kubernetes: link_to('Kubernetes cluster', project_clusters_path(project))
} }
if missing_domain if missing_domain?
_('Auto Review Apps and Auto Deploy need a domain name and a %{kubernetes} to work correctly.') % params _('Auto Review Apps and Auto Deploy need a domain name and a %{kubernetes} to work correctly.') % params
else else
_('Auto Review Apps and Auto Deploy need a %{kubernetes} to work correctly.') % params _('Auto Review Apps and Auto Deploy need a %{kubernetes} to work correctly.') % params
end end
elsif missing_domain elsif missing_domain?
_('Auto Review Apps and Auto Deploy need a domain name to work correctly.') _('Auto Review Apps and Auto Deploy need a domain name to work correctly.')
end end
end end
private
def missing_domain?
!(project.auto_devops&.has_domain? || current_application_settings.auto_devops_domain.present?)
end
def missing_service?
!project.deployment_platform&.active?
end
end end
...@@ -82,4 +82,39 @@ describe AutoDevopsHelper do ...@@ -82,4 +82,39 @@ describe AutoDevopsHelper do
it { is_expected.to eq(false) } it { is_expected.to eq(false) }
end end
end end
describe '.auto_devops_warning_message' do
subject { helper.auto_devops_warning_message(project) }
context 'when the service is missing' do
before do
allow(helper).to receive(:missing_service?).and_return(true)
end
context 'when the domain is missing' do
before do
allow(helper).to receive(:missing_domain?).and_return(true)
end
it { is_expected.to match(/Auto Review Apps and Auto Deploy need a domain name and a .* to work correctly./) }
end
context 'when the domain is not missing' do
before do
allow(helper).to receive(:missing_domain?).and_return(false)
end
it { is_expected.to match(/Auto Review Apps and Auto Deploy need a .* to work correctly./) }
end
end
context 'when the domain is missing' do
before do
allow(helper).to receive(:missing_service?).and_return(false)
allow(helper).to receive(:missing_domain?).and_return(true)
end
it { is_expected.to eq('Auto Review Apps and Auto Deploy need a domain name to work correctly.') }
end
end
end end
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