Fix missing validations on Signup (#4674)

* Fix missing validations on Signup

This commit fixes issue
https://github.com/plataformatec/devise/issues/4673

This removes `validate: false` from saving a record when `Trackable` is
in use.

* Add test case

* Add mongoid model
This commit is contained in:
Ashley Foster
2017-11-28 09:58:41 -05:00
committed by Leonardo Tegon
parent ce0414271a
commit 31801fc9a0
6 changed files with 61 additions and 1 deletions

View File

@@ -4,4 +4,6 @@ class User < ActiveRecord::Base
include Shim
include SharedUser
include ActiveModel::Serializers::Xml if Devise::Test.rails5?
validates :sign_in_count, presence: true
end

View File

@@ -0,0 +1,10 @@
require 'shared_user'
class UserWithValidations < ActiveRecord::Base
self.table_name = 'users'
include Shim
include SharedUser
validates :email, presence: true
end

View File

@@ -0,0 +1,35 @@
require "shared_user"
class UserWithValidations
include Mongoid::Document
include Shim
include SharedUser
field :username, type: String
field :facebook_token, type: String
## Database authenticatable
field :email, type: String, default: ""
field :encrypted_password, type: String, default: ""
## Recoverable
field :reset_password_token, type: String
field :reset_password_sent_at, type: Time
## Rememberable
field :remember_created_at, type: Time
## Trackable
field :sign_in_count, type: Integer, default: 0
field :current_sign_in_at, type: Time
field :last_sign_in_at, type: Time
field :current_sign_in_ip, type: String
field :last_sign_in_ip, type: String
## Lockable
field :failed_attempts, type: Integer, default: 0 # Only if lock strategy is :failed_attempts
field :unlock_token, type: String # Only if unlock strategy is :email or :both
field :locked_at, type: Time
validates :email, presence: true
end