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
df206331
Commit
df206331
authored
Aug 08, 2017
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Switch source to source_id
parent
84dd5610
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
36 additions
and
4 deletions
+36
-4
db/migrate/20170808005254_add_email_opted_in_fields_to_users.rb
...rate/20170808005254_add_email_opted_in_fields_to_users.rb
+1
-1
db/schema.rb
db/schema.rb
+1
-1
ee/app/controllers/ee/registrations_controller.rb
ee/app/controllers/ee/registrations_controller.rb
+1
-1
ee/app/models/ee/user.rb
ee/app/models/ee/user.rb
+6
-0
ee/app/services/ee/users/build_service.rb
ee/app/services/ee/users/build_service.rb
+1
-1
spec/ee/spec/models/ee/user_spec.rb
spec/ee/spec/models/ee/user_spec.rb
+26
-0
No files found.
db/migrate/20170808005254_add_email_opted_in_fields_to_users.rb
View file @
df206331
...
@@ -9,7 +9,7 @@ class AddEmailOptedInFieldsToUsers < ActiveRecord::Migration
...
@@ -9,7 +9,7 @@ class AddEmailOptedInFieldsToUsers < ActiveRecord::Migration
def
change
def
change
add_column
:users
,
:email_opted_in
,
:boolean
,
null:
true
add_column
:users
,
:email_opted_in
,
:boolean
,
null:
true
add_column
:users
,
:email_opted_in_ip
,
:string
,
null:
true
add_column
:users
,
:email_opted_in_ip
,
:string
,
null:
true
add_column
:users
,
:email_opted_in_source
,
:string
,
null:
true
add_column
:users
,
:email_opted_in_source
_id
,
:integer
,
null:
true
add_column
:users
,
:email_opted_in_at
,
:datetime_with_timezone
,
null:
true
add_column
:users
,
:email_opted_in_at
,
:datetime_with_timezone
,
null:
true
end
end
end
end
db/schema.rb
View file @
df206331
...
@@ -1906,7 +1906,7 @@ ActiveRecord::Schema.define(version: 20170808163512) do
...
@@ -1906,7 +1906,7 @@ ActiveRecord::Schema.define(version: 20170808163512) do
t
.
string
"email_provider"
t
.
string
"email_provider"
t
.
boolean
"email_opted_in"
t
.
boolean
"email_opted_in"
t
.
string
"email_opted_in_ip"
t
.
string
"email_opted_in_ip"
t
.
string
"email_opted_in_source
"
t
.
integer
"email_opted_in_source_id
"
t
.
datetime_with_timezone
"email_opted_in_at"
t
.
datetime_with_timezone
"email_opted_in_at"
end
end
...
...
ee/app/controllers/ee/registrations_controller.rb
View file @
df206331
...
@@ -11,7 +11,7 @@ module EE
...
@@ -11,7 +11,7 @@ module EE
if
clean_params
[
:email_opted_in
]
==
'1'
if
clean_params
[
:email_opted_in
]
==
'1'
clean_params
[
:email_opted_in_ip
]
=
request
.
remote_ip
clean_params
[
:email_opted_in_ip
]
=
request
.
remote_ip
clean_params
[
:email_opted_in_source
]
=
'GitLab.com'
clean_params
[
:email_opted_in_source
_id
]
=
User
::
EMAIL_OPT_IN_SOURCE_ID_GITLAB_COM
clean_params
[
:email_opted_in_at
]
=
Time
.
zone
.
now
clean_params
[
:email_opted_in_at
]
=
Time
.
zone
.
now
end
end
...
...
ee/app/models/ee/user.rb
View file @
df206331
...
@@ -8,6 +8,8 @@ module EE
...
@@ -8,6 +8,8 @@ module EE
include
AuditorUserHelper
include
AuditorUserHelper
included
do
included
do
EMAIL_OPT_IN_SOURCE_ID_GITLAB_COM
=
1
# We aren't using the `auditor?` method for the `if` condition here
# We aren't using the `auditor?` method for the `if` condition here
# because `auditor?` returns `false` when the `auditor` column is `true`
# because `auditor?` returns `false` when the `auditor` column is `true`
# and the auditor add-on absent. We want to run this validation
# and the auditor add-on absent. We want to run this validation
...
@@ -91,5 +93,9 @@ module EE
...
@@ -91,5 +93,9 @@ module EE
return
if
::
Gitlab
::
Geo
.
secondary?
return
if
::
Gitlab
::
Geo
.
secondary?
super
super
end
end
def
email_opted_in_source
email_opted_in_source_id
==
EMAIL_OPT_IN_SOURCE_ID_GITLAB_COM
?
'GitLab.com'
:
''
end
end
end
end
end
ee/app/services/ee/users/build_service.rb
View file @
df206331
...
@@ -14,7 +14,7 @@ module EE
...
@@ -14,7 +14,7 @@ module EE
:username
,
:username
,
:email_opted_in
,
:email_opted_in
,
:email_opted_in_ip
,
:email_opted_in_ip
,
:email_opted_in_source
,
:email_opted_in_source
_id
,
:email_opted_in_at
:email_opted_in_at
]
]
end
end
...
...
spec/ee/spec/models/ee/user_spec.rb
View file @
df206331
...
@@ -105,4 +105,30 @@ describe EE::User do
...
@@ -105,4 +105,30 @@ describe EE::User do
expect
{
subject
.
remember_me!
}.
not_to
change
(
subject
,
:remember_created_at
)
expect
{
subject
.
remember_me!
}.
not_to
change
(
subject
,
:remember_created_at
)
end
end
end
end
describe
'#email_opted_in_source'
do
context
'for GitLab.com'
do
let
(
:user
)
{
build
(
:user
,
email_opted_in_source_id:
1
)
}
it
'returns GitLab.com'
do
expect
(
user
.
email_opted_in_source
).
to
eq
(
'GitLab.com'
)
end
end
context
'for nil source id'
do
let
(
:user
)
{
build
(
:user
,
email_opted_in_source_id:
nil
)
}
it
'returns blank'
do
expect
(
user
.
email_opted_in_source
).
to
be_blank
end
end
context
'for non-existent source id'
do
let
(
:user
)
{
build
(
:user
,
email_opted_in_source_id:
2
)
}
it
'returns blank'
do
expect
(
user
.
email_opted_in_source
).
to
be_blank
end
end
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