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
1012b1c2
Commit
1012b1c2
authored
Aug 07, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Capture email opt-in source and timestamp
parent
72f8a090
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
25 additions
and
7 deletions
+25
-7
ee/app/controllers/ee/registrations_controller.rb
ee/app/controllers/ee/registrations_controller.rb
+5
-1
ee/app/services/ee/users/build_service.rb
ee/app/services/ee/users/build_service.rb
+3
-1
spec/ee/spec/controllers/ee/registrations_controller_spec.rb
spec/ee/spec/controllers/ee/registrations_controller_spec.rb
+9
-3
spec/ee/spec/features/signup_spec.rb
spec/ee/spec/features/signup_spec.rb
+8
-2
No files found.
ee/app/controllers/ee/registrations_controller.rb
View file @
1012b1c2
...
...
@@ -7,7 +7,11 @@ module EE
def
sign_up_params
clean_params
=
params
.
require
(
:user
).
permit
(
:username
,
:email
,
:email_confirmation
,
:name
,
:password
,
:email_opted_in
)
clean_params
[
:email_opted_in_ip
]
=
clean_params
[
:email_opted_in
]
==
'1'
?
request
.
remote_ip
:
nil
if
clean_params
[
:email_opted_in
]
==
'1'
clean_params
[
:email_opted_in_ip
]
=
request
.
remote_ip
clean_params
[
:email_opted_in_source
]
=
'GitLab.com'
clean_params
[
:email_opted_in_at
]
=
Time
.
zone
.
now
end
clean_params
end
...
...
ee/app/services/ee/users/build_service.rb
View file @
1012b1c2
...
...
@@ -13,7 +13,9 @@ module EE
:password
,
:username
,
:email_opted_in
,
:email_opted_in_ip
:email_opted_in_ip
,
:email_opted_in_source
,
:email_opted_in_at
]
end
end
...
...
spec/ee/spec/controllers/ee/registrations_controller_spec.rb
View file @
1012b1c2
...
...
@@ -7,20 +7,26 @@ describe RegistrationsController do
context
'when the user opted-in'
do
let
(
:email_opted_in
)
{
'1'
}
it
'sets
email_opted_in_ip to an IP
'
do
it
'sets
the rest of the email_opted_in fields
'
do
post
:create
,
user_params
user
=
User
.
find_by_username
(
'new_username'
)
expect
(
user
.
email_opted_in
).
to
be_truthy
expect
(
user
.
email_opted_in_ip
).
to
be_present
expect
(
user
.
email_opted_in_source
).
to
eq
(
'GitLab.com'
)
expect
(
user
.
email_opted_in_at
).
not_to
be_nil
end
end
context
'when the user opted-out'
do
let
(
:email_opted_in
)
{
'0'
}
it
'
sets email_opted_in_ip to nil
'
do
it
'
does not set the rest of the email_opted_in fields
'
do
post
:create
,
user_params
user
=
User
.
find_by_username
(
'new_username'
)
expect
(
user
.
email_opted_in_ip
).
to
be_nil
expect
(
user
.
email_opted_in
).
to
be_falsey
expect
(
user
.
email_opted_in_ip
).
to
be_blank
expect
(
user
.
email_opted_in_source
).
to
be_blank
expect
(
user
.
email_opted_in_at
).
to
be_nil
end
end
end
...
...
spec/ee/spec/features/signup_spec.rb
View file @
1012b1c2
...
...
@@ -23,6 +23,8 @@ feature 'Signup on EE' do
user
=
User
.
find_by_username!
(
user
.
username
)
expect
(
user
.
email_opted_in
).
to
be_truthy
expect
(
user
.
email_opted_in_ip
).
to
be_present
expect
(
user
.
email_opted_in_source
).
to
eq
(
'GitLab.com'
)
expect
(
user
.
email_opted_in_at
).
not_to
be_nil
end
end
...
...
@@ -41,7 +43,9 @@ feature 'Signup on EE' do
user
=
User
.
find_by_username!
(
user
.
username
)
expect
(
user
.
email_opted_in
).
to
be_falsey
expect
(
user
.
email_opted_in_ip
).
to
be_nil
expect
(
user
.
email_opted_in_ip
).
to
be_blank
expect
(
user
.
email_opted_in_source
).
to
be_blank
expect
(
user
.
email_opted_in_at
).
to
be_nil
end
end
end
...
...
@@ -67,7 +71,9 @@ feature 'Signup on EE' do
user
=
User
.
find_by_username!
(
user
.
username
)
expect
(
user
.
email_opted_in
).
to
be_falsey
expect
(
user
.
email_opted_in_ip
).
to
be_nil
expect
(
user
.
email_opted_in_ip
).
to
be_blank
expect
(
user
.
email_opted_in_source
).
to
be_blank
expect
(
user
.
email_opted_in_at
).
to
be_nil
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