diff options
author | Matija Čupić <matteeyah@gmail.com> | 2018-02-01 23:29:11 +0100 |
---|---|---|
committer | Matija Čupić <matteeyah@gmail.com> | 2018-02-01 23:29:11 +0100 |
commit | a31539847fd431e18053d0ea5a007dc38134b3f2 (patch) | |
tree | f8ee50942f485ac3729e9f6fdb62e1d09d1ab5e4 | |
parent | 5126b1c5d3ba71a3ddad7e59142e46344b4c0eda (diff) | |
download | gitlab-ce-a31539847fd431e18053d0ea5a007dc38134b3f2.tar.gz |
Add specs for .auto_devops_warning_message
-rw-r--r-- | app/helpers/auto_devops_helper.rb | 19 | ||||
-rw-r--r-- | spec/helpers/auto_devops_helper_spec.rb | 35 |
2 files changed, 48 insertions, 6 deletions
diff --git a/app/helpers/auto_devops_helper.rb b/app/helpers/auto_devops_helper.rb index d72457efec0..898ad2d304b 100644 --- a/app/helpers/auto_devops_helper.rb +++ b/app/helpers/auto_devops_helper.rb @@ -9,21 +9,28 @@ module AutoDevopsHelper end def auto_devops_warning_message(project) - missing_domain = !project.auto_devops&.has_domain? - missing_service = !project.deployment_platform&.active? - - if missing_service + if missing_service? params = { 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 else _('Auto Review Apps and Auto Deploy need a %{kubernetes} to work correctly.') % params end - elsif missing_domain + elsif missing_domain? _('Auto Review Apps and Auto Deploy need a domain name to work correctly.') 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 diff --git a/spec/helpers/auto_devops_helper_spec.rb b/spec/helpers/auto_devops_helper_spec.rb index 5e272af6073..1fcbad5875d 100644 --- a/spec/helpers/auto_devops_helper_spec.rb +++ b/spec/helpers/auto_devops_helper_spec.rb @@ -82,4 +82,39 @@ describe AutoDevopsHelper do it { is_expected.to eq(false) } 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 |