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
4f0b3463
Commit
4f0b3463
authored
Aug 07, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Save opted_in_to_emails checkbox on sign up
parent
4885e789
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
109 additions
and
0 deletions
+109
-0
app/controllers/registrations_controller.rb
app/controllers/registrations_controller.rb
+1
-0
app/services/users/build_service.rb
app/services/users/build_service.rb
+2
-0
app/views/devise/shared/_signup_box.html.haml
app/views/devise/shared/_signup_box.html.haml
+1
-0
ee/app/controllers/ee/registrations_controller.rb
ee/app/controllers/ee/registrations_controller.rb
+11
-0
ee/app/services/ee/users/build_service.rb
ee/app/services/ee/users/build_service.rb
+20
-0
ee/app/views/devise/shared/ee/_email_opted_in.html.haml
ee/app/views/devise/shared/ee/_email_opted_in.html.haml
+4
-0
spec/ee/spec/features/signup_spec.rb
spec/ee/spec/features/signup_spec.rb
+70
-0
No files found.
app/controllers/registrations_controller.rb
View file @
4f0b3463
class
RegistrationsController
<
Devise
::
RegistrationsController
include
Recaptcha
::
Verify
prepend
EE
::
RegistrationsController
def
new
redirect_to
(
new_user_session_path
)
...
...
app/services/users/build_service.rb
View file @
4f0b3463
module
Users
class
BuildService
<
BaseService
prepend
::
EE
::
Users
::
BuildService
def
initialize
(
current_user
,
params
=
{})
@current_user
=
current_user
@params
=
params
.
dup
...
...
app/views/devise/shared/_signup_box.html.haml
View file @
4f0b3463
...
...
@@ -22,6 +22,7 @@
=
f
.
label
:password
=
f
.
password_field
:password
,
class:
"form-control bottom"
,
required:
true
,
pattern:
".{
#{
@minimum_password_length
}
,}"
,
title:
"Minimum length is
#{
@minimum_password_length
}
characters."
%p
.gl-field-hint
Minimum length is
#{
@minimum_password_length
}
characters
=
render
'devise/shared/ee/email_opted_in'
,
f:
f
%div
-
if
Gitlab
::
Recaptcha
.
enabled?
=
recaptcha_tags
...
...
ee/app/controllers/ee/registrations_controller.rb
0 → 100644
View file @
4f0b3463
module
EE
module
RegistrationsController
extend
ActiveSupport
::
Concern
private
def
sign_up_params
params
.
require
(
:user
).
permit
(
:username
,
:email
,
:email_confirmation
,
:name
,
:password
,
:email_opted_in
)
end
end
end
ee/app/services/ee/users/build_service.rb
0 → 100644
View file @
4f0b3463
module
EE
module
Users
module
BuildService
private
def
signup_params
[
:email
,
:email_confirmation
,
:password_automatically_set
,
:name
,
:password
,
:username
,
:email_opted_in
]
end
end
end
end
ee/app/views/devise/shared/ee/_email_opted_in.html.haml
0 → 100644
View file @
4f0b3463
-
if
Gitlab
.
com?
.form-group
=
f
.
check_box
:email_opted_in
=
f
.
label
:email_opted_in
,
"I'd like to receive updates via email about GitLab."
spec/ee/spec/features/signup_spec.rb
0 → 100644
View file @
4f0b3463
require
'spec_helper'
feature
'Signup on EE'
do
context
'for Gitlab.com'
do
before
do
expect
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
true
).
at_least
(
:once
)
end
context
'when the user checks the opt-in to email updates box'
do
it
'creates the user and sets the email_opted_in field truthy'
do
user
=
build
(
:user
)
visit
root_path
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_email_confirmation'
,
with:
user
.
email
fill_in
'new_user_password'
,
with:
user
.
password
check
'new_user_email_opted_in'
click_button
"Register"
user
=
User
.
find_by_username!
(
user
.
username
)
expect
(
user
.
email_opted_in
).
to
be_truthy
end
end
context
'when the user does not check the opt-in to email updates box'
do
it
'creates the user and sets the email_opted_in field falsey'
do
user
=
build
(
:user
)
visit
root_path
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_email_confirmation'
,
with:
user
.
email
fill_in
'new_user_password'
,
with:
user
.
password
click_button
"Register"
user
=
User
.
find_by_username!
(
user
.
username
)
expect
(
user
.
email_opted_in
).
to
be_falsey
end
end
end
context
'not for Gitlab.com'
do
before
do
expect
(
Gitlab
).
to
receive
(
:com?
).
and_return
(
false
).
at_least
(
:once
)
end
it
'does not have a opt-in checkbox, it creates the user and sets email_opted_in to falsey'
do
user
=
build
(
:user
)
visit
root_path
expect
(
page
).
not_to
have_selector
(
"[name='new_user_email_opted_in']"
)
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_email_confirmation'
,
with:
user
.
email
fill_in
'new_user_password'
,
with:
user
.
password
click_button
"Register"
user
=
User
.
find_by_username!
(
user
.
username
)
expect
(
user
.
email_opted_in
).
to
be_falsey
end
end
end
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