Commit 2a0b4ad1 authored by Jason Goodman's avatar Jason Goodman Committed by Stan Hu

Refactor registration features prompt shared examples

Fix warning about redefining shared examples
parent e8a5daa9
# frozen_string_literal: true
RSpec.shared_examples 'renders registration features prompt' do |disabled_field, feature_title|
it 'renders a placeholder input with registration features message' do
render
if disabled_field
expect(rendered).to have_field(disabled_field, disabled: true)
end
expect(rendered).to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: feature_title || s_('RegistrationFeatures|use this feature') })
expect(rendered).to have_link(s_('RegistrationFeatures|Enable Service Ping and register for this feature.'))
expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
end
RSpec.shared_examples 'does not render registration features prompt' do |disabled_field, feature_title|
RSpec.shared_examples 'does not render registration features prompt' do |disabled_field|
it 'does not render a placeholder input with registration features message' do
render
......@@ -22,7 +8,7 @@ RSpec.shared_examples 'does not render registration features prompt' do |disable
expect(rendered).not_to have_field(disabled_field, disabled: true)
end
expect(rendered).not_to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: feature_title || s_('RegistrationFeatures|use this feature') })
expect(rendered).not_to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') })
expect(rendered).not_to have_link(s_('RegistrationFeatures|Enable Service Ping and register for this feature.'))
expect(rendered).not_to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
......
......@@ -89,7 +89,14 @@ RSpec.describe 'groups/edit.html.haml' do
allow(License).to receive(:current).and_return(nil)
end
it_behaves_like 'renders registration features prompt', :group_disabled_ip_restriction_ranges
it 'renders a placeholder input with registration features message' do
render
expect(rendered).to have_field(:group_disabled_ip_restriction_ranges, disabled: true)
expect(rendered).to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') })
expect(rendered).to have_link(s_('RegistrationFeatures|Enable Service Ping and register for this feature.'))
expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
end
context 'with a valid license' do
......
# frozen_string_literal: true
RSpec.shared_examples 'renders registration features prompt' do |disabled_field, feature_title|
it 'renders a placeholder input with registration features message' do
render
if disabled_field
expect(rendered).to have_field(disabled_field, disabled: true)
end
expect(rendered).to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: feature_title || s_('RegistrationFeatures|use this feature') })
expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
end
RSpec.shared_examples 'does not render registration features prompt' do |disabled_field, feature_title|
it 'does not render a placeholder input with registration features message' do
render
if disabled_field
expect(rendered).not_to have_field(disabled_field, disabled: true)
end
expect(rendered).not_to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: feature_title || s_('RegistrationFeatures|use this feature') })
expect(rendered).not_to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
end
......@@ -139,7 +139,13 @@ RSpec.describe 'groups/edit.html.haml' do
stub_application_setting(usage_ping_enabled: false)
end
it_behaves_like 'renders registration features prompt', :group_disabled_ip_restriction_ranges
it 'renders a placeholder input with registration features message' do
render
expect(rendered).to have_field(:group_disabled_ip_restriction_ranges, disabled: true)
expect(rendered).to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') })
expect(rendered).to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
end
context 'with service ping enabled' do
......@@ -147,7 +153,13 @@ RSpec.describe 'groups/edit.html.haml' do
stub_application_setting(usage_ping_enabled: true)
end
it_behaves_like 'does not render registration features prompt', :group_disabled_ip_restriction_ranges
it 'does not render a placeholder input with registration features message' do
render
expect(rendered).not_to have_field(:group_disabled_ip_restriction_ranges, disabled: true)
expect(rendered).not_to have_content(s_("RegistrationFeatures|Want to %{feature_title} for free?") % { feature_title: s_('RegistrationFeatures|use this feature') })
expect(rendered).not_to have_link(s_('RegistrationFeatures|Registration Features Program'))
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