Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
203a58cf
Commit
203a58cf
authored
Sep 28, 2021
by
Jay
Committed by
Etienne Baqué
Sep 28, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Persist jobs_to_be_done answers to DB
parent
a0ddad33
Changes
16
Hide whitespace changes
Inline
Side-by-side
Showing
16 changed files
with
51 additions
and
34 deletions
+51
-34
app/models/user.rb
app/models/user.rb
+1
-0
app/models/user_detail.rb
app/models/user_detail.rb
+5
-0
db/migrate/20210917224419_add_registration_objective_to_user_detail.rb
...210917224419_add_registration_objective_to_user_detail.rb
+7
-0
db/schema_migrations/20210917224419
db/schema_migrations/20210917224419
+1
-0
db/structure.sql
db/structure.sql
+1
-0
ee/app/assets/javascripts/registrations/welcome/jobs_to_be_done.js
...sets/javascripts/registrations/welcome/jobs_to_be_done.js
+1
-1
ee/app/controllers/ee/registrations/welcome_controller.rb
ee/app/controllers/ee/registrations/welcome_controller.rb
+1
-1
ee/app/helpers/ee/registrations_helper.rb
ee/app/helpers/ee/registrations_helper.rb
+8
-11
ee/app/views/registrations/welcome/_jobs_to_be_done.html.haml
...pp/views/registrations/welcome/_jobs_to_be_done.html.haml
+2
-4
ee/spec/controllers/registrations/welcome_controller_spec.rb
ee/spec/controllers/registrations/welcome_controller_spec.rb
+10
-1
ee/spec/features/registrations/welcome_spec.rb
ee/spec/features/registrations/welcome_spec.rb
+1
-1
ee/spec/helpers/ee/registrations_helper_spec.rb
ee/spec/helpers/ee/registrations_helper_spec.rb
+6
-14
ee/spec/views/registrations/welcome/show.html.haml_spec.rb
ee/spec/views/registrations/welcome/show.html.haml_spec.rb
+1
-1
spec/models/namespace_setting_spec.rb
spec/models/namespace_setting_spec.rb
+2
-0
spec/models/user_detail_spec.rb
spec/models/user_detail_spec.rb
+1
-0
spec/models/user_spec.rb
spec/models/user_spec.rb
+3
-0
No files found.
app/models/user.rb
View file @
203a58cf
...
...
@@ -318,6 +318,7 @@ class User < ApplicationRecord
delegate
:webauthn_xid
,
:webauthn_xid
=
,
to: :user_detail
,
allow_nil:
true
delegate
:pronouns
,
:pronouns
=
,
to: :user_detail
,
allow_nil:
true
delegate
:pronunciation
,
:pronunciation
=
,
to: :user_detail
,
allow_nil:
true
delegate
:registration_objective
,
:registration_objective
=
,
to: :user_detail
,
allow_nil:
true
accepts_nested_attributes_for
:user_preference
,
update_only:
true
accepts_nested_attributes_for
:user_detail
,
update_only:
true
...
...
app/models/user_detail.rb
View file @
203a58cf
...
...
@@ -3,8 +3,11 @@
class
UserDetail
<
ApplicationRecord
extend
::
Gitlab
::
Utils
::
Override
include
IgnorableColumns
ignore_columns
%i[bio_html cached_markdown_version]
,
remove_with:
'13.6'
,
remove_after:
'2021-10-22'
REGISTRATION_OBJECTIVE_PAIRS
=
{
basics:
0
,
move_repository:
1
,
code_storage:
2
,
exploring:
3
,
ci:
4
,
other:
5
,
joining_team:
6
}.
freeze
belongs_to
:user
validates
:pronouns
,
length:
{
maximum:
50
}
...
...
@@ -14,6 +17,8 @@ class UserDetail < ApplicationRecord
before_save
:prevent_nil_bio
enum
registration_objective:
REGISTRATION_OBJECTIVE_PAIRS
,
_suffix:
true
private
def
prevent_nil_bio
...
...
db/migrate/20210917224419_add_registration_objective_to_user_detail.rb
0 → 100644
View file @
203a58cf
# frozen_string_literal: true
class
AddRegistrationObjectiveToUserDetail
<
Gitlab
::
Database
::
Migration
[
1.0
]
def
change
add_column
:user_details
,
:registration_objective
,
:smallint
end
end
db/schema_migrations/20210917224419
0 → 100644
View file @
203a58cf
9204c844b22ad0d3a938ed908377c8baacdda038725a5cf105e4b11841c1ae21
\ No newline at end of file
db/structure.sql
View file @
203a58cf
...
...
@@ -19762,6 +19762,7 @@ CREATE TABLE user_details (
provisioned_by_group_id bigint,
pronouns text,
pronunciation text,
registration_objective smallint,
CONSTRAINT check_245664af82 CHECK ((char_length(webauthn_xid) <= 100)),
CONSTRAINT check_b132136b01 CHECK ((char_length(other_role) <= 100)),
CONSTRAINT check_eeeaf8d4f0 CHECK ((char_length(pronouns) <= 50)),
ee/app/assets/javascripts/registrations/welcome/jobs_to_be_done.js
View file @
203a58cf
...
...
@@ -4,7 +4,7 @@ import Tracking from '~/tracking';
const
select
=
document
.
querySelector
(
'
.js-jobs-to-be-done-dropdown
'
);
if
(
select
)
{
Tracking
.
enableFormTracking
(
{
fields
:
{
allow
:
[
'
jobs_to_be_done
'
,
'
jobs_to_be_done
_other
'
]
}
},
{
fields
:
{
allow
:
[
'
jobs_to_be_done_other
'
]
}
},
getExperimentContexts
(
'
jobs_to_be_done
'
),
);
...
...
ee/app/controllers/ee/registrations/welcome_controller.rb
View file @
203a58cf
...
...
@@ -44,7 +44,7 @@ module EE
override
:update_params
def
update_params
clean_params
=
super
.
merge
(
params
.
require
(
:user
).
permit
(
:email_opted_in
))
clean_params
=
super
.
merge
(
params
.
require
(
:user
).
permit
(
:email_opted_in
,
:registration_objective
))
return
clean_params
unless
::
Gitlab
.
dev_env_or_com?
...
...
ee/app/helpers/ee/registrations_helper.rb
View file @
203a58cf
...
...
@@ -10,8 +10,10 @@ module EE
super
.
merge
(
api_path:
suggestion_path
)
end
def
shuffled_jobs_to_be_done_options
jobs_to_be_done_options
.
shuffle
.
append
([
_
(
'A different reason'
),
'other'
])
def
shuffled_registration_objective_options
options
=
registration_objective_options
other
=
options
.
extract!
(
:other
).
to_a
.
flatten
options
.
to_a
.
shuffle
.
append
(
other
).
map
{
|
option
|
option
.
reverse
}
end
private
...
...
@@ -23,15 +25,10 @@ module EE
end
end
def
jobs_to_be_done_options
[
_
(
'I want to learn the basics of Git'
),
_
(
'I want to move my repository to GitLab from somewhere else'
),
_
(
'I want to store my code'
),
_
(
'I want to explore GitLab to see if it’s worth switching to'
),
_
(
'I want to use GitLab CI with my existing repository'
),
_
(
'I’m joining my team who’s already on GitLab'
)
]
def
registration_objective_options
localized_jobs_to_be_done_choices
.
merge
(
joining_team:
_
(
'I’m joining my team who’s already on GitLab'
)
)
end
end
end
ee/app/views/registrations/welcome/_jobs_to_be_done.html.haml
View file @
203a58cf
...
...
@@ -2,10 +2,8 @@
-
e
.
try
do
.row
.form-group.col-sm-12
=
label_tag
:jobs_to_be_done
,
_
(
"I'm signing up for GitLab because:"
)
=
select_tag
:jobs_to_be_done
,
options_for_select
(
shuffled_jobs_to_be_done_options
),
include_blank:
_
(
'Please select...'
),
class:
'form-control js-jobs-to-be-done-dropdown'
=
label_tag
:user_registration_objective
,
_
(
"I'm signing up for GitLab because:"
)
=
f
.
select
:registration_objective
,
shuffled_registration_objective_options
,
{
include_blank:
_
(
'Please select...'
)
},
class:
'form-control js-jobs-to-be-done-dropdown'
.row
.form-group.col-sm-12.js-jobs-to-be-done-other-group.hidden
=
label_tag
:jobs_to_be_done_other
,
_
(
'Why are you signing up? (Optional)'
)
...
...
ee/spec/controllers/registrations/welcome_controller_spec.rb
View file @
203a58cf
...
...
@@ -135,7 +135,8 @@ RSpec.describe Registrations::WelcomeController do
user:
{
role:
'software_developer'
,
setup_for_company:
setup_for_company
,
email_opted_in:
email_opted_in
email_opted_in:
email_opted_in
,
registration_objective:
'code_storage'
}
}
end
...
...
@@ -179,6 +180,14 @@ RSpec.describe Registrations::WelcomeController do
allow
(
::
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
)
end
context
'when registration_objective field is provided'
do
it
'sets the registration_objective'
do
subject
expect
(
controller
.
current_user
.
registration_objective
).
to
eq
(
'code_storage'
)
end
end
context
'when setup for company is false'
do
context
'when the user opted in'
do
let
(
:email_opted_in
)
{
'1'
}
...
...
ee/spec/features/registrations/welcome_spec.rb
View file @
203a58cf
...
...
@@ -59,7 +59,7 @@ RSpec.describe 'Welcome screen', :js do
it
'allows specifying other for the jobs_to_be_done experiment'
,
:experiment
do
expect
(
page
).
not_to
have_content
(
'Why are you signing up? (Optional)'
)
select
'A different reason'
,
from:
'
jobs_to_be_don
e'
select
'A different reason'
,
from:
'
user_registration_objectiv
e'
expect
(
page
).
to
have_content
(
'Why are you signing up? (Optional)'
)
...
...
ee/spec/helpers/ee/registrations_helper_spec.rb
View file @
203a58cf
...
...
@@ -9,25 +9,17 @@ RSpec.describe EE::RegistrationsHelper do
end
end
describe
'#shuffled_
jobs_to_be_don
e_options'
do
subject
{
helper
.
shuffled_jobs_to_be_don
e_options
}
describe
'#shuffled_
registration_objectiv
e_options'
do
subject
(
:shuffled_options
)
{
helper
.
shuffled_registration_objectiv
e_options
}
let
(
:array_double
)
{
double
(
:array
)
}
it
'has values that match all UserDetail registration objective keys'
do
shuffled_option_values
=
shuffled_options
.
map
{
|
item
|
item
.
last
}
it
'uses shuffle'
do
allow
(
helper
).
to
receive
(
:jobs_to_be_done_options
).
and_return
(
array_double
)
expect
(
array_double
).
to
receive
(
:shuffle
).
and_return
([])
subject
end
it
'has a number of options'
do
expect
(
subject
.
count
).
to
eq
(
7
)
expect
(
shuffled_option_values
).
to
contain_exactly
(
*
UserDetail
.
registration_objectives
.
keys
)
end
it
'"other" is always the last option'
do
expect
(
s
ubject
.
last
).
to
eq
([
'A different reason'
,
'other'
])
expect
(
s
huffled_options
.
last
).
to
eq
([
'A different reason'
,
'other'
])
end
end
end
ee/spec/views/registrations/welcome/show.html.haml_spec.rb
View file @
203a58cf
...
...
@@ -66,7 +66,7 @@ RSpec.describe 'registrations/welcome/show' do
let_it_be
(
:stubbed_experiments
)
{
{
jobs_to_be_done: :candidate
}
}
it
'renders a select and text field for additional information'
do
is_expected
.
to
have_selector
(
'select[name="
jobs_to_be_done
"]'
)
is_expected
.
to
have_selector
(
'select[name="
user[registration_objective]
"]'
)
is_expected
.
to
have_selector
(
'input[name="jobs_to_be_done_other"]'
,
visible:
false
)
end
end
...
...
spec/models/namespace_setting_spec.rb
View file @
203a58cf
...
...
@@ -11,6 +11,8 @@ RSpec.describe NamespaceSetting, type: :model do
it
{
is_expected
.
to
belong_to
(
:namespace
)
}
end
it
{
is_expected
.
to
define_enum_for
(
:jobs_to_be_done
).
with_values
([
:basics
,
:move_repository
,
:code_storage
,
:exploring
,
:ci
,
:other
]).
with_suffix
}
describe
"validations"
do
describe
"#default_branch_name_content"
do
let_it_be
(
:group
)
{
create
(
:group
)
}
...
...
spec/models/user_detail_spec.rb
View file @
203a58cf
...
...
@@ -4,6 +4,7 @@ require 'spec_helper'
RSpec
.
describe
UserDetail
do
it
{
is_expected
.
to
belong_to
(
:user
)
}
it
{
is_expected
.
to
define_enum_for
(
:registration_objective
).
with_values
([
:basics
,
:move_repository
,
:code_storage
,
:exploring
,
:ci
,
:other
,
:joining_team
]).
with_suffix
}
describe
'validations'
do
describe
'#job_title'
do
...
...
spec/models/user_spec.rb
View file @
203a58cf
...
...
@@ -79,6 +79,9 @@ RSpec.describe User do
it
{
is_expected
.
to
delegate_method
(
:bio
).
to
(
:user_detail
).
allow_nil
}
it
{
is_expected
.
to
delegate_method
(
:bio
=
).
to
(
:user_detail
).
with_arguments
(
:args
).
allow_nil
}
it
{
is_expected
.
to
delegate_method
(
:registration_objective
).
to
(
:user_detail
).
allow_nil
}
it
{
is_expected
.
to
delegate_method
(
:registration_objective
=
).
to
(
:user_detail
).
with_arguments
(
:args
).
allow_nil
}
end
describe
'associations'
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment