Commit 83cc2c5f authored by Mikołaj Wawrzyniak's avatar Mikołaj Wawrzyniak

Merge branch '341949-in-app-awareness-of-registration-features-feature-based-cta-2' into 'master'

In-app awareness of Registration Features - Group access by IP address

See merge request gitlab-org/gitlab!74022
parents ef09594c 70dad3a4
- 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 @@
= render 'groups/settings/project_access_token_creation', 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/allowed_email_domain', f: f, group: @group
= 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
let(:ranges) { ['192.168.0.0/24'] }
it_behaves_like 'renders ip_restriction setting'
it_behaves_like 'does not render registration features prompt'
end
context 'with multiple subnets' do
let(:ranges) { ['192.168.0.0/24', '192.168.1.0/8'] }
it_behaves_like 'renders ip_restriction setting'
it_behaves_like 'does not render registration features prompt'
end
end
end
......@@ -75,6 +77,39 @@ RSpec.describe 'groups/edit.html.haml' do
it_behaves_like 'does not render ip_restriction setting'
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
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
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
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