add rss_token attribute to user model
This commit is contained in:
parent
c013d23d63
commit
3713a57fe8
5 changed files with 32 additions and 2 deletions
|
@ -15,6 +15,7 @@ class User < ActiveRecord::Base
|
|||
|
||||
add_authentication_token_field :authentication_token
|
||||
add_authentication_token_field :incoming_email_token
|
||||
add_authentication_token_field :rss_token
|
||||
|
||||
default_value_for :admin, false
|
||||
default_value_for(:external) { current_application_settings.user_default_external }
|
||||
|
@ -152,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
|
||||
before_save :ensure_authentication_token, :ensure_incoming_email_token, :ensure_rss_token
|
||||
before_save :ensure_external_user_rights
|
||||
after_save :ensure_namespace_correct
|
||||
after_initialize :set_projects_limit
|
||||
|
|
|
@ -65,6 +65,7 @@ module Gitlab
|
|||
hook
|
||||
import_url
|
||||
incoming_email_token
|
||||
rss_token
|
||||
key
|
||||
otp_attempt
|
||||
password
|
||||
|
|
19
db/migrate/20170523091700_add_rss_token_to_users.rb
Normal file
19
db/migrate/20170523091700_add_rss_token_to_users.rb
Normal file
|
@ -0,0 +1,19 @@
|
|||
class AddRssTokenToUsers < ActiveRecord::Migration
|
||||
include Gitlab::Database::MigrationHelpers
|
||||
|
||||
DOWNTIME = false
|
||||
|
||||
disable_ddl_transaction!
|
||||
|
||||
def up
|
||||
add_column :users, :rss_token, :string
|
||||
|
||||
add_concurrent_index :users, :rss_token
|
||||
end
|
||||
|
||||
def down
|
||||
remove_concurrent_index :users, :rss_token if index_exists? :users, :rss_token
|
||||
|
||||
remove_column :users, :rss_token
|
||||
end
|
||||
end
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170521184006) do
|
||||
ActiveRecord::Schema.define(version: 20170523091700) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
@ -1362,6 +1362,7 @@ ActiveRecord::Schema.define(version: 20170521184006) do
|
|||
t.date "last_activity_on"
|
||||
t.boolean "notified_of_own_activity"
|
||||
t.string "preferred_language"
|
||||
t.string "rss_token"
|
||||
end
|
||||
|
||||
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
|
||||
|
@ -1375,6 +1376,7 @@ ActiveRecord::Schema.define(version: 20170521184006) do
|
|||
add_index "users", ["name"], name: "index_users_on_name", using: :btree
|
||||
add_index "users", ["name"], name: "index_users_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"}
|
||||
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
|
||||
add_index "users", ["rss_token"], name: "index_users_on_rss_token", using: :btree
|
||||
add_index "users", ["state"], name: "index_users_on_state", using: :btree
|
||||
add_index "users", ["username"], name: "index_users_on_username", using: :btree
|
||||
add_index "users", ["username"], name: "index_users_on_username_trigram", using: :gin, opclasses: {"username"=>"gin_trgm_ops"}
|
||||
|
|
|
@ -440,6 +440,13 @@ describe User, models: true do
|
|||
end
|
||||
end
|
||||
|
||||
describe 'rss token' do
|
||||
it 'has rss token' do
|
||||
user = create(:user)
|
||||
expect(user.rss_token).not_to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
describe '#recently_sent_password_reset?' do
|
||||
it 'is false when reset_password_sent_at is nil' do
|
||||
user = build_stubbed(:user, reset_password_sent_at: nil)
|
||||
|
|
Loading…
Reference in a new issue