Commit 174311b1 authored by Mayra Cabrera's avatar Mayra Cabrera

Merge branch...

Merge branch '221028-skip-the-who-will-be-using-gitlab-question-in-signup-when-a-user-is-invited' into 'master'

Skip the who question in signup when a user is invited

See merge request gitlab-org/gitlab!42264
parents f5f1a283 70df9386
......@@ -61,6 +61,10 @@ module EE
experiment_enabled?(:onboarding_issues)
end
def skip_setup_for_company?
current_user.members.any?
end
private
def redirect_path
......
- if Gitlab.com?
- return unless Gitlab.dev_env_or_com?
- if skip_setup_for_company?
= f.hidden_field :setup_for_company, value: true
- else
.row
.form-group.col-sm-12
= f.label :setup_for_company, setup_for_company_label_text, class: 'label-bold'
......
---
title: Skip the who will be using GitLab question in signup when a user is invited
merge_request: 42264
author:
type: changed
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'Group or Project invitations' do
let(:group) { create(:group, name: 'Owned') }
let(:project) { create(:project, :repository, namespace: group) }
let(:group_invite) { create(:group_member, :invited, group: group) }
let(:new_user) { build_stubbed(:user, email: group_invite.invite_email) }
let(:dev_env_or_com) { true }
before do
allow(::Gitlab).to receive(:dev_env_or_com?).and_return(dev_env_or_com)
visit invite_path(group_invite.raw_invite_token)
end
def fill_in_sign_up_form(user)
fill_in 'new_user_name', with: user.name
fill_in 'new_user_username', with: user.username
fill_in 'new_user_email', with: user.email
fill_in 'new_user_password', with: user.password
click_button 'Register'
end
context 'when on .com' do
context 'without setup question' do
it 'bypasses the setup_for_company question' do
fill_in_sign_up_form(new_user)
expect(find('input[name="user[setup_for_company]"]', visible: :hidden).value).to eq 'true'
expect(page).not_to have_content('My company or team')
end
end
context 'with setup question' do
let(:new_user) { build_stubbed(:user, email: 'bogus@me.com') }
it 'has the setup question' do
fill_in_sign_up_form(new_user)
expect(page).to have_content('My company or team')
end
end
end
context 'when not on .com' do
let(:dev_env_or_com) { false }
it 'bypasses the setup_for_company question' do
fill_in_sign_up_form(new_user)
expect(page).not_to have_content('My company or team')
end
end
end
......@@ -244,4 +244,23 @@ RSpec.describe EE::RegistrationsHelper do
end
end
end
describe '#skip_setup_for_company?' do
let(:user) { create(:user) }
before do
allow(helper).to receive(:current_user).and_return(user)
end
it 'will skip the setup if memberships are found' do
member = create(:project_member, :invited)
member.accept_invite!(user)
expect(helper.skip_setup_for_company?).to be true
end
it 'will not skip the setup when a user has no memberships' do
expect(helper.skip_setup_for_company?).to be false
end
end
end
......@@ -2,7 +2,7 @@
require 'spec_helper'
RSpec.describe 'Invites', :aggregate_failures do
RSpec.describe 'Group or Project invitations', :aggregate_failures do
let(:user) { create(:user, email: 'user@example.com') }
let(:owner) { create(:user, name: 'John Doe') }
let(:group) { create(:group, name: 'Owned') }
......
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