Commit 70dad3a4 authored by Axel García's avatar Axel García Committed by Mikołaj Wawrzyniak

Registration features info for ip restriction

Changelog: added
MR: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/74022
EE: true
parent e3d7c020
- return unless registration_features_can_be_prompted?
.form-group
= f.label :disabled_ip_restriction_ranges, class: 'label-bold' do
= _('Allow access to the following IP addresses')
= f.text_field :disabled_ip_restriction_ranges, value: '', class: 'form-control', disabled: true
%span.form-text.text-muted
= render 'shared/registration_features_discovery_message'
...@@ -31,6 +31,7 @@ ...@@ -31,6 +31,7 @@
= render 'groups/settings/project_access_token_creation', f: f, group: @group = render 'groups/settings/project_access_token_creation', f: f, group: @group
= render_if_exists 'groups/settings/delayed_project_removal', f: f, group: @group = render_if_exists 'groups/settings/delayed_project_removal', f: f, group: @group
= render 'groups/settings/ip_restriction_registration_features_cta', f: f
= render_if_exists 'groups/settings/ip_restriction', f: f, group: @group = render_if_exists 'groups/settings/ip_restriction', f: f, group: @group
= render_if_exists 'groups/settings/allowed_email_domain', f: f, group: @group = render_if_exists 'groups/settings/allowed_email_domain', f: f, group: @group
= render 'groups/settings/lfs', f: f = render 'groups/settings/lfs', f: f
......
# 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|
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|Enable Service Ping and register for this feature.'))
expect(rendered).not_to have_link(s_('RegistrationFeatures|Registration Features Program'))
end
end
...@@ -52,12 +52,14 @@ RSpec.describe 'groups/edit.html.haml' do ...@@ -52,12 +52,14 @@ RSpec.describe 'groups/edit.html.haml' do
let(:ranges) { ['192.168.0.0/24'] } let(:ranges) { ['192.168.0.0/24'] }
it_behaves_like 'renders ip_restriction setting' it_behaves_like 'renders ip_restriction setting'
it_behaves_like 'does not render registration features prompt'
end end
context 'with multiple subnets' do context 'with multiple subnets' do
let(:ranges) { ['192.168.0.0/24', '192.168.1.0/8'] } let(:ranges) { ['192.168.0.0/24', '192.168.1.0/8'] }
it_behaves_like 'renders ip_restriction setting' it_behaves_like 'renders ip_restriction setting'
it_behaves_like 'does not render registration features prompt'
end end
end end
end end
...@@ -75,6 +77,39 @@ RSpec.describe 'groups/edit.html.haml' do ...@@ -75,6 +77,39 @@ RSpec.describe 'groups/edit.html.haml' do
it_behaves_like 'does not render ip_restriction setting' it_behaves_like 'does not render ip_restriction setting'
end end
context 'prompt user about registration features' do
context 'with service ping disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
end
context 'with no license' do
before do
allow(License).to receive(:current).and_return(nil)
end
it_behaves_like 'renders registration features prompt', :group_disabled_ip_restriction_ranges
end
context 'with a valid license' do
before do
license = build(:license)
allow(License).to receive(:current).and_return(license)
end
it_behaves_like 'does not render registration features prompt', :group_disabled_ip_restriction_ranges
end
end
context 'with service ping enabled' do
before do
stub_application_setting(usage_ping_enabled: true)
end
it_behaves_like 'does not render registration features prompt', :group_disabled_ip_restriction_ranges
end
end
end end
context 'allowed_email_domain' do context 'allowed_email_domain' 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
...@@ -115,4 +115,40 @@ RSpec.describe 'groups/edit.html.haml' do ...@@ -115,4 +115,40 @@ RSpec.describe 'groups/edit.html.haml' do
end end
end end
end end
context 'ip_restriction' do
let(:group) { create(:group) }
let(:user) { create(:user) }
before do
group.add_owner(user)
assign(:group, group)
allow(view).to receive(:current_user) { user }
end
context 'prompt user about registration features' do
before do
if Gitlab.ee?
allow(License).to receive(:current).and_return(nil)
end
end
context 'with service ping disabled' do
before do
stub_application_setting(usage_ping_enabled: false)
end
it_behaves_like 'renders registration features prompt', :group_disabled_ip_restriction_ranges
end
context 'with service ping enabled' do
before do
stub_application_setting(usage_ping_enabled: true)
end
it_behaves_like 'does not render registration features prompt', :group_disabled_ip_restriction_ranges
end
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