BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
2f277d10
Commit
2f277d10
authored
May 23, 2017
by
Alexis Reigel
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
ensure rss token on read
we do this on attribute read since migrating all existing users is not a feasible solution.
parent
dfc2542f
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
13 additions
and
4 deletions
+13
-4
user.rb
app/models/user.rb
+8
-1
user_spec.rb
spec/models/user_spec.rb
+5
-3
No files found.
app/models/user.rb
View file @
2f277d10
...
...
@@ -153,7 +153,7 @@ class User < ActiveRecord::Base
before_validation
:set_public_email
,
if:
->
(
user
)
{
user
.
public_email_changed?
}
after_update
:update_emails_with_primary_email
,
if:
->
(
user
)
{
user
.
email_changed?
}
before_save
:ensure_authentication_token
,
:ensure_incoming_email_token
,
:ensure_rss_token
before_save
:ensure_authentication_token
,
:ensure_incoming_email_token
before_save
:ensure_external_user_rights
after_save
:ensure_namespace_correct
after_initialize
:set_projects_limit
...
...
@@ -1005,6 +1005,13 @@ class User < ActiveRecord::Base
save
end
# each existing user needs to have an `rss_token`.
# we do this on read since migrating all existing users is not a feasible
# solution.
def
rss_token
ensure_rss_token!
end
protected
# override, from Devise::Validatable
...
...
spec/models/user_spec.rb
View file @
2f277d10
...
...
@@ -448,9 +448,11 @@ describe User, models: true do
end
describe
'rss token'
do
it
'has rss token'
do
user
=
create
(
:user
)
expect
(
user
.
rss_token
).
not_to
be_blank
it
'ensures an rss token on read'
do
user
=
create
(
:user
,
rss_token:
nil
)
rss_token
=
user
.
rss_token
expect
(
rss_token
).
not_to
be_blank
expect
(
user
.
reload
.
rss_token
).
to
eq
rss_token
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