Commit 685dc56a authored by Alper Akgun's avatar Alper Akgun Committed by Adam Hegyi

Capture other role details during signup

Use text field to capture further details of Other role type during
sign up
parent d3c93ccd
......@@ -45,7 +45,7 @@ module Registrations
end
def update_params
params.require(:user).permit(:role, :setup_for_company)
params.require(:user).permit(:role, :other_role, :setup_for_company)
end
def requires_confirmation?(user)
......
......@@ -289,6 +289,7 @@ class User < ApplicationRecord
delegate :path, to: :namespace, allow_nil: true, prefix: true
delegate :job_title, :job_title=, to: :user_detail, allow_nil: true
delegate :other_role, :other_role=, to: :user_detail, allow_nil: true
delegate :bio, :bio=, :bio_html, to: :user_detail, allow_nil: true
delegate :webauthn_xid, :webauthn_xid=, to: :user_detail, allow_nil: true
......
......@@ -14,8 +14,16 @@
.row
.form-group.col-sm-12
= f.label :role, _('Role'), class: 'label-bold'
= f.select :role, ::User.roles.keys.map { |role| [role.titleize, role] }, {}, class: 'form-control', autofocus: true
.form-text.gl-text-gray-500.gl-mt-3= _('This will help us personalize your onboarding experience.')
= f.select :role, ::User.roles.keys.map { |role| [role.titleize, role] }, {}, class: 'form-control js-user-role-dropdown', autofocus: true
- if Feature.enabled?(:user_other_role_details)
.row
.form-group.col-sm-12.js-other-role-group{ class: ("hidden") }
= f.label :other_role, _('What is your job title? (optional)'), class: 'form-check-label gl-mb-3'
= f.text_field :other_role, class: 'form-control'
- else
.row
.form-group.col-sm-12
.form-text.gl-text-gray-500.gl-mt-0.gl-line-height-normal.gl-px-1= _('This will help us personalize your onboarding experience.')
= render_if_exists "registrations/welcome/setup_for_company", f: f
.row
.form-group.col-sm-12.gl-mb-0
......
---
title: Add other role column in user details table
merge_request: 45635
author:
type: added
---
name: user_other_role_details
introduced_by_url: https://gitlab.com/gitlab-org/gitlab/-/merge_requests/45635
rollout_issue_url: https://gitlab.com/gitlab-org/gitlab/-/issues/255170
milestone: '13.7'
type: development
group: group::conversion
default_enabled: false
# frozen_string_literal: true
class AddOtherRoleToUserDetails < ActiveRecord::Migration[6.0]
include Gitlab::Database::MigrationHelpers
DOWNTIME = false
disable_ddl_transaction!
def up
unless column_exists?(:user_details, :other_role)
with_lock_retries do
add_column :user_details, :other_role, :text
end
end
add_text_limit :user_details, :other_role, 100
end
def down
with_lock_retries do
remove_column :user_details, :other_role
end
end
end
70fae11d6a73ea8b2ad75c574716f48e9cc78a58ae23db48e74840646fd46672
\ No newline at end of file
......@@ -16961,7 +16961,9 @@ CREATE TABLE user_details (
bio_html text,
cached_markdown_version integer,
webauthn_xid text,
CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100))
other_role text,
CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)),
CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100))
);
CREATE SEQUENCE user_details_user_id_seq
......
import Vue from 'vue';
import 'ee/registrations/welcome/other_role';
import { parseBoolean } from '~/lib/utils/common_utils';
import {
STEPS,
......
const role = document.querySelector('.js-user-role-dropdown');
const otherRoleGroup = document.querySelector('.js-other-role-group');
role.addEventListener('change', () => {
const enableOtherRole = role.value === 'other';
otherRoleGroup.classList.toggle('hidden', !enableOtherRole);
});
role.dispatchEvent(new Event('change'));
......@@ -75,6 +75,71 @@ RSpec.describe 'Signup on EE' do
end
end
context 'when the user_other_role_details feature flag is disabled' do
before do
stub_feature_flags(user_other_role_details: false)
end
context 'collects no collect a job title' do
it 'proceeds to the next step without collecting other_role' do
fill_in_signup_form
click_button "Register"
select 'Other', from: 'user_role'
expect(page).not_to have_field('What is your job title? (optional)')
choose 'user_setup_for_company_false'
click_button 'Get started!'
user = User.find_by_username!(new_user[:username])
expect(user.other_role).to be_blank
end
end
end
context 'when the user selects existing role' do
let_it_be(:job_title) { 'Guardian of the galaxy' }
it 'has the job title box' do
expect(page).not_to have_field('What is your job title? (optional)')
end
it 'proceeds to the next step' do
fill_in_signup_form
click_button "Register"
select 'Software Developer', from: 'user_role'
choose 'user_setup_for_company_false'
click_button 'Get started!'
user = User.find_by_username!(new_user[:username])
expect(user.other_role).to be_blank
end
end
context 'when the user selects other role' do
let_it_be(:job_title) { 'Guardian of the galaxy' }
it 'has the job title box' do
expect(page).not_to have_field('What is your job title? (optional)')
end
it 'proceeds to the next step' do
fill_in_signup_form
click_button "Register"
select 'Other', from: 'user_role'
expect(page).to have_field('What is your job title? (optional)')
choose 'user_setup_for_company_false'
fill_in 'What is your job title? (optional)', with: job_title
click_button 'Get started!'
user = User.find_by_username!(new_user[:username])
expect(user.other_role).to eq(job_title)
end
end
it 'redirects to step 2 of the signup process, sets the role and setup for company and redirects back' do
fill_in_signup_form
click_button 'Register'
......
......@@ -6,12 +6,14 @@ RSpec.describe 'registrations/welcome/show' do
using RSpec::Parameterized::TableSyntax
let_it_be(:user) { User.new }
let_it_be(:user_other_role_details_enabled) { false }
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(:onboarding_issues_experiment_enabled?).and_return(onboarding_issues_experiment_enabled)
allow(Gitlab).to receive(:com?).and_return(true)
stub_feature_flags(user_other_role_details: user_other_role_details_enabled)
render
end
......@@ -49,5 +51,14 @@ RSpec.describe 'registrations/welcome/show' do
else
it { is_expected.not_to have_selector('#progress-bar') }
end
context 'feature flag other_role_details is enabled' do
let_it_be(:user_other_role_details_enabled) { true }
it 'has a text field for other role' do
is_expected.not_to have_selector('input[type="hidden"][name="user[other_role]"]', visible: false)
is_expected.to have_selector('input[type="text"][name="user[other_role]"]')
end
end
end
end
......@@ -30649,6 +30649,9 @@ msgstr ""
msgid "What is squashing?"
msgstr ""
msgid "What is your job title? (optional)"
msgstr ""
msgid "What's new at GitLab"
msgstr ""
......
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