Commit 5864a15b authored by Miguel Rincon's avatar Miguel Rincon

Merge branch 'remove-marketing-email-opt-in-for-self-managed' into 'master'

Remove marketing email opt-in for self-managed

See merge request gitlab-org/gitlab!66255
parents ef310205 3e23d77a
......@@ -41,7 +41,7 @@ module Registrations
end
def update_params
params.require(:user).permit(:role, :other_role, :setup_for_company, :email_opted_in)
params.require(:user).permit(:role, :other_role, :setup_for_company)
end
def requires_confirmation?(user)
......
- is_hidden = local_assigns.fetch(:hidden, Gitlab.dev_env_or_com?)
- return unless Gitlab.dev_env_or_com?
.gl-mb-3.js-email-opt-in{ class: is_hidden ? 'hidden' : '' }
.gl-mb-3.js-email-opt-in.hidden
.gl-font-weight-bold.gl-mb-3
= _('Email updates (optional)')
= f.check_box :email_opted_in
......
......@@ -38,7 +38,7 @@ module EE
override :update_params
def update_params
clean_params = super
clean_params = super.merge(params.require(:user).permit(:email_opted_in))
return clean_params unless ::Gitlab.dev_env_or_com?
......
......@@ -5,16 +5,20 @@ require 'spec_helper'
RSpec.describe 'registrations/welcome/show' do
using RSpec::Parameterized::TableSyntax
describe 'forms and progress bar' do
let_it_be(:user) { create(:user) }
before do
allow(view).to receive(:current_user).and_return(user)
allow(Gitlab).to receive(:com?).and_return(true)
end
describe 'forms and progress bar' do
let_it_be(:user_other_role_details_enabled) { false }
let_it_be(:stubbed_experiments) { {} }
before do
allow(view).to receive(:current_user).and_return(user)
allow(view).to receive(:redirect_path).and_return(redirect_path)
allow(view).to receive(:signup_onboarding_enabled?).and_return(signup_onboarding_enabled)
allow(Gitlab).to receive(:com?).and_return(true)
stub_feature_flags(user_other_role_details: user_other_role_details_enabled)
stub_experiments(stubbed_experiments)
......@@ -78,4 +82,11 @@ RSpec.describe 'registrations/welcome/show' do
is_expected.not_to have_selector('#progress-bar')
end
end
context 'rendering the hidden email opt in checkbox' do
subject { render }
it { is_expected.to have_selector('input[name="user[email_opted_in]"]') }
it { is_expected.to have_css('.js-email-opt-in.hidden') }
end
end
......@@ -60,10 +60,8 @@ RSpec.describe Registrations::WelcomeController do
end
describe '#update' do
let(:email_opted_in) { '0' }
subject(:update) do
patch :update, params: { user: { role: 'software_developer', setup_for_company: 'false', email_opted_in: email_opted_in } }
patch :update, params: { user: { role: 'software_developer', setup_for_company: 'false' } }
end
context 'without a signed in user' do
......@@ -100,24 +98,6 @@ RSpec.describe Registrations::WelcomeController do
end
end
end
context 'when the user opted in' do
let(:email_opted_in) { '1' }
it 'sets the email_opted_in field' do
subject
expect(controller.current_user.email_opted_in).to eq(true)
end
end
context 'when the user opted out' do
it 'sets the email_opted_in field' do
subject
expect(controller.current_user.email_opted_in).to eq(false)
end
end
end
end
end
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Welcome screen' do
let(:user) { create(:user) }
before do
gitlab_sign_in(user)
visit users_sign_up_welcome_path
end
it 'shows the email opt in' do
select 'Software Developer', from: 'user_role'
check 'user_email_opted_in'
click_button 'Get started!'
expect(user.reload.email_opted_in).to eq(true)
end
end
......@@ -3,8 +3,6 @@
require 'spec_helper'
RSpec.describe 'registrations/welcome/show' do
let(:is_gitlab_com) { false }
let_it_be(:user) { create(:user) }
before do
......@@ -13,7 +11,6 @@ RSpec.describe 'registrations/welcome/show' do
allow(view).to receive(:in_trial_flow?).and_return(false)
allow(view).to receive(:user_has_memberships?).and_return(false)
allow(view).to receive(:in_oauth_flow?).and_return(false)
allow(Gitlab).to receive(:com?).and_return(is_gitlab_com)
render
end
......@@ -22,24 +19,5 @@ RSpec.describe 'registrations/welcome/show' do
it { is_expected.not_to have_selector('label[for="user_setup_for_company"]') }
it { is_expected.to have_button('Get started!') }
it { is_expected.to have_selector('input[name="user[email_opted_in]"]') }
describe 'email opt in' do
context 'when on gitlab.com' do
let(:is_gitlab_com) { true }
it 'hides the email-opt in by default' do
expect(subject).to have_css('.js-email-opt-in.hidden')
end
end
context 'when not on gitlab.com' do
let(:is_gitlab_com) { false }
it 'hides the email-opt in by default' do
expect(subject).not_to have_css('.js-email-opt-in.hidden')
expect(subject).to have_css('.js-email-opt-in')
end
end
end
it { is_expected.not_to have_selector('input[name="user[email_opted_in]"]') }
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