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
ac26518f
Commit
ac26518f
authored
Aug 07, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Capture email opt-in IP
parent
4f0b3463
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
39 additions
and
4 deletions
+39
-4
ee/app/controllers/ee/registrations_controller.rb
ee/app/controllers/ee/registrations_controller.rb
+6
-2
ee/app/services/ee/users/build_service.rb
ee/app/services/ee/users/build_service.rb
+3
-2
spec/ee/spec/controllers/ee/registrations_controller_spec.rb
spec/ee/spec/controllers/ee/registrations_controller_spec.rb
+27
-0
spec/ee/spec/features/signup_spec.rb
spec/ee/spec/features/signup_spec.rb
+3
-0
No files found.
ee/app/controllers/ee/registrations_controller.rb
View file @
ac26518f
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
)
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
clean_params
end
end
end
ee/app/services/ee/users/build_service.rb
View file @
ac26518f
...
...
@@ -3,7 +3,7 @@ module EE
module
BuildService
private
def
signup_params
[
:email
,
...
...
@@ -12,7 +12,8 @@ module EE
:name
,
:password
,
:username
,
:email_opted_in
:email_opted_in
,
:email_opted_in_ip
]
end
end
...
...
spec/ee/spec/controllers/ee/registrations_controller_spec.rb
0 → 100644
View file @
ac26518f
require
'spec_helper'
describe
RegistrationsController
do
describe
'#create'
do
let
(
:user_params
)
{
{
user:
{
name:
'new_user'
,
username:
'new_username'
,
email:
'new@user.com'
,
password:
'Any_password'
,
email_opted_in:
email_opted_in
}
}
}
context
'when the user opted-in'
do
let
(
:email_opted_in
)
{
'1'
}
it
'sets email_opted_in_ip to an IP'
do
post
:create
,
user_params
user
=
User
.
find_by_username
(
'new_username'
)
expect
(
user
.
email_opted_in_ip
).
to
be_present
end
end
context
'when the user opted-out'
do
let
(
:email_opted_in
)
{
'0'
}
it
'sets email_opted_in_ip to nil'
do
post
:create
,
user_params
user
=
User
.
find_by_username
(
'new_username'
)
expect
(
user
.
email_opted_in_ip
).
to
be_nil
end
end
end
end
spec/ee/spec/features/signup_spec.rb
View file @
ac26518f
...
...
@@ -22,6 +22,7 @@ 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
end
end
...
...
@@ -40,6 +41,7 @@ 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
end
end
end
...
...
@@ -65,6 +67,7 @@ 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
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