Commit 33f49978 authored by Robert Speicher's avatar Robert Speicher

Merge branch...

Merge branch '262845-engineering-experiment-with-adding-social-sign-in-options-to-trial-registration-page' into 'master'

Add social sign up options to trial registration page

See merge request gitlab-org/gitlab!45633
parents 712c33ca e620feb8
...@@ -113,6 +113,10 @@ module AuthHelper ...@@ -113,6 +113,10 @@ module AuthHelper
end end
end end
def experiment_enabled_button_based_providers
enabled_button_based_providers & %w(google_oauth2 github).freeze
end
def button_based_providers_enabled? def button_based_providers_enabled?
enabled_button_based_providers.any? enabled_button_based_providers.any?
end end
......
- max_first_name_length = max_last_name_length = 127 - max_first_name_length = max_last_name_length = 127
- max_username_length = 255 - max_username_length = 255
- min_username_length = 2 - min_username_length = 2
- omniauth_providers_placement ||= :bottom
.gl-mb-3.gl-p-4.gl-border-gray-100.gl-border-1.gl-border-solid.gl-rounded-base .gl-mb-3.gl-p-4.gl-border-gray-100.gl-border-1.gl-border-solid.gl-rounded-base
- if show_omniauth_providers && omniauth_providers_placement == :top
= render 'devise/shared/signup_omniauth_providers_top'
= form_for(resource, as: "new_#{resource_name}", url: url, html: { class: 'new_user gl-show-field-errors', 'aria-live' => 'assertive' }) do |f| = form_for(resource, as: "new_#{resource_name}", url: url, html: { class: 'new_user gl-show-field-errors', 'aria-live' => 'assertive' }) do |f|
.devise-errors .devise-errors
= render 'devise/shared/error_messages', resource: resource = render 'devise/shared/error_messages', resource: resource
...@@ -33,5 +38,5 @@ ...@@ -33,5 +38,5 @@
.submit-container .submit-container
= f.submit button_text, class: 'btn gl-button btn-success', data: { qa_selector: 'new_user_register_button' } = f.submit button_text, class: 'btn gl-button btn-success', data: { qa_selector: 'new_user_register_button' }
= render 'devise/shared/terms_of_service_notice' = render 'devise/shared/terms_of_service_notice'
- if show_omniauth_providers - if show_omniauth_providers && omniauth_providers_placement == :bottom
= render 'devise/shared/signup_omniauth_providers' = render 'devise/shared/signup_omniauth_providers'
%label.label-bold.d-block
= _("Create an account using:")
.d-flex.justify-content-between.flex-wrap
- providers.each do |provider|
= link_to omniauth_authorize_path(:user, provider), method: :post, class: "btn gl-button gl-display-flex gl-align-items-center gl-text-left gl-mb-2 gl-p-2 omniauth-btn oauth-login #{qa_class_for_provider(provider)}", id: "oauth-login-#{provider}" do
- if provider_has_icon?(provider)
= provider_image_tag(provider)
%span.ml-2
= label_for_provider(provider)
.omniauth-divider.d-flex.align-items-center.text-center .omniauth-divider.d-flex.align-items-center.text-center
= _("or") = _("or")
%label.label-bold.d-block = render 'devise/shared/signup_omniauth_provider_list', providers: enabled_button_based_providers
= _("Create an account using:")
- providers = enabled_button_based_providers
.d-flex.justify-content-between.flex-wrap
- providers.each do |provider|
- has_icon = provider_has_icon?(provider)
= link_to omniauth_authorize_path(:user, provider), method: :post, class: "gl-button btn d-flex align-items-center omniauth-btn text-left oauth-login mb-2 p-2 #{qa_class_for_provider(provider)}", id: "oauth-login-#{provider}" do
- if has_icon
= provider_image_tag(provider)
%span.ml-2
= label_for_provider(provider)
= render 'devise/shared/signup_omniauth_provider_list', providers: experiment_enabled_button_based_providers
.omniauth-divider.d-flex.align-items-center.text-center
= _("or")
...@@ -15,6 +15,7 @@ class TrialsController < ApplicationController ...@@ -15,6 +15,7 @@ class TrialsController < ApplicationController
def new def new
record_experiment_user(:remove_known_trial_form_fields, remove_known_trial_form_fields_context) record_experiment_user(:remove_known_trial_form_fields, remove_known_trial_form_fields_context)
record_experiment_user(:trimmed_skip_trial_copy) record_experiment_user(:trimmed_skip_trial_copy)
record_experiment_user(:trial_registration_with_social_signin, trial_registration_with_social_signin_context)
end end
def select def select
...@@ -38,6 +39,8 @@ class TrialsController < ApplicationController ...@@ -38,6 +39,8 @@ class TrialsController < ApplicationController
if @result&.dig(:success) if @result&.dig(:success)
record_experiment_conversion_event(:remove_known_trial_form_fields) record_experiment_conversion_event(:remove_known_trial_form_fields)
record_experiment_conversion_event(:trimmed_skip_trial_copy) record_experiment_conversion_event(:trimmed_skip_trial_copy)
record_experiment_conversion_event(:trial_registration_with_social_signin)
redirect_to group_url(@namespace, { trial: true }) redirect_to group_url(@namespace, { trial: true })
else else
render :select render :select
...@@ -123,4 +126,13 @@ class TrialsController < ApplicationController ...@@ -123,4 +126,13 @@ class TrialsController < ApplicationController
company_name_present: current_user.organization.present? company_name_present: current_user.organization.present?
} }
end end
def trial_registration_with_social_signin_context
identities = current_user.identities.map(&:provider)
{
google_signon: identities.include?('google_oauth2'),
github_signon: identities.include?('github')
}
end
end end
# frozen_string_literal: true
module EE
module TrialRegistrationHelper
def social_signin_experiment_enabled?
::Gitlab.com? &&
omniauth_enabled? &&
devise_mapping.omniauthable? &&
button_based_providers_enabled? &&
experiment_enabled?(:trial_registration_with_social_signin)
end
end
end
...@@ -8,5 +8,10 @@ ...@@ -8,5 +8,10 @@
= _('Start a Free Gold Trial') = _('Start a Free Gold Trial')
.signup-page .signup-page
= render 'devise/shared/signup_box', url: trial_registrations_path, button_text: _('Continue'), show_omniauth_providers: false = render 'devise/shared/signup_box',
url: trial_registrations_path,
button_text: _('Continue'),
show_omniauth_providers: social_signin_experiment_enabled?,
omniauth_providers_placement: :top
= render 'devise/shared/sign_in_link' = render 'devise/shared/sign_in_link'
...@@ -12,6 +12,13 @@ RSpec.describe TrialsController do ...@@ -12,6 +12,13 @@ RSpec.describe TrialsController do
} }
end end
let_it_be(:trial_registration_with_social_signin_context) do
{
google_signon: user.identities.select { |id| id.provider == 'google_auth2'}.present?,
github_signon: user.identities.select { |id| id.provider == 'github' }.present?
}
end
let(:dev_env_or_com) { true } let(:dev_env_or_com) { true }
let(:logged_in) { true } let(:logged_in) { true }
...@@ -54,9 +61,10 @@ RSpec.describe TrialsController do ...@@ -54,9 +61,10 @@ RSpec.describe TrialsController do
response response
end end
it 'calls record_experiment_user for the remove_known_trial_form_fields & trimmed_skip_trial_copy experiments' do it 'calls record_experiment_user for the experiments' do
expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields, remove_known_trial_form_fields_context) expect(controller).to receive(:record_experiment_user).with(:remove_known_trial_form_fields, remove_known_trial_form_fields_context)
expect(controller).to receive(:record_experiment_user).with(:trimmed_skip_trial_copy) expect(controller).to receive(:record_experiment_user).with(:trimmed_skip_trial_copy)
expect(controller).to receive(:record_experiment_user).with(:trial_registration_with_social_signin, trial_registration_with_social_signin_context)
subject subject
end end
...@@ -197,9 +205,10 @@ RSpec.describe TrialsController do ...@@ -197,9 +205,10 @@ RSpec.describe TrialsController do
let(:apply_trial_result) { true } let(:apply_trial_result) { true }
it { is_expected.to redirect_to("/#{namespace.path}?trial=true") } it { is_expected.to redirect_to("/#{namespace.path}?trial=true") }
it 'calls the record conversion method for the remove_known_trial_form_fields & trimmed_skip_trial_copy experiments' do it 'calls the record conversion method for the experiments' do
expect(controller).to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields) expect(controller).to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields)
expect(controller).to receive(:record_experiment_conversion_event).with(:trimmed_skip_trial_copy) expect(controller).to receive(:record_experiment_conversion_event).with(:trimmed_skip_trial_copy)
expect(controller).to receive(:record_experiment_conversion_event).with(:trial_registration_with_social_signin)
subject subject
end end
...@@ -217,9 +226,10 @@ RSpec.describe TrialsController do ...@@ -217,9 +226,10 @@ RSpec.describe TrialsController do
let(:apply_trial_result) { false } let(:apply_trial_result) { false }
it { is_expected.to render_template(:select) } it { is_expected.to render_template(:select) }
it 'does not call the record conversion method for the remove_known_trial_form_fields & trimmed_skip_trial_copy experiments' do it 'does not call the record conversion method for the experiments' do
expect(controller).not_to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields) expect(controller).not_to receive(:record_experiment_conversion_event).with(:remove_known_trial_form_fields)
expect(controller).not_to receive(:record_experiment_conversion_event).with(:trimmed_skip_trial_copy) expect(controller).not_to receive(:record_experiment_conversion_event).with(:trimmed_skip_trial_copy)
expect(controller).not_to receive(:record_experiment_conversion_event).with(:trial_registration_with_social_signin)
subject subject
end end
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe EE::TrialRegistrationHelper do
using RSpec::Parameterized::TableSyntax
describe '#social_signin_experiment_enabled?' do
before do
allow(::Gitlab).to receive(:com?).and_return(com)
allow(view).to receive(:omniauth_enabled?).and_return(omniauth_enabled)
allow(view).to receive(:button_based_providers_enabled?).and_return(button_based_providers_enabled)
allow(view).to receive(:experiment_enabled?).with(:trial_registration_with_social_signin).and_return(experiment_enabled)
allow(view).to receive(:devise_mapping).and_return(double(omniauthable?: omniauthable))
end
subject { helper.social_signin_experiment_enabled? }
where com: [true, false],
omniauth_enabled: [true, false],
omniauthable: [true, false],
button_based_providers_enabled: [true, false],
experiment_enabled: [true, false]
with_them do
let(:result) { com && omniauth_enabled && button_based_providers_enabled && experiment_enabled && omniauthable }
it { is_expected.to eq(result) }
end
end
end
...@@ -81,6 +81,9 @@ module Gitlab ...@@ -81,6 +81,9 @@ module Gitlab
}, },
trimmed_skip_trial_copy: { trimmed_skip_trial_copy: {
tracking_category: 'Growth::Conversion::Experiment::TrimmedSkipTrialCopy' tracking_category: 'Growth::Conversion::Experiment::TrimmedSkipTrialCopy'
},
trial_registration_with_social_signin: {
tracking_category: 'Growth::Conversion::Experiment::TrialRegistrationWithSocialSigning'
} }
}.freeze }.freeze
......
...@@ -99,6 +99,22 @@ RSpec.describe AuthHelper do ...@@ -99,6 +99,22 @@ RSpec.describe AuthHelper do
end end
end end
describe 'experiment_enabled_button_based_providers' do
it 'returns the intersection set of github & google_oauth2 with enabled providers' do
allow(helper).to receive(:enabled_button_based_providers) { %w(twitter github google_oauth2) }
expect(helper.experiment_enabled_button_based_providers).to eq(%w(github google_oauth2))
allow(helper).to receive(:enabled_button_based_providers) { %w(google_oauth2 bitbucket) }
expect(helper.experiment_enabled_button_based_providers).to eq(%w(google_oauth2))
allow(helper).to receive(:enabled_button_based_providers) { %w(bitbucket) }
expect(helper.experiment_enabled_button_based_providers).to be_empty
end
end
describe 'button_based_providers_enabled?' do describe 'button_based_providers_enabled?' do
before do before do
allow(helper).to receive(:auth_providers) { [:twitter, :github] } allow(helper).to receive(:auth_providers) { [:twitter, :github] }
......
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