1
0
Fork 0
mirror of https://github.com/heartcombo/devise.git synced 2022-11-09 12:18:31 -05:00

Adding required_fields to all modules

This commit is contained in:
Rodrigo Flores 2012-02-24 20:56:04 -02:00
parent 6d5bccc050
commit 5ef35ee1bd
8 changed files with 41 additions and 0 deletions

View file

@ -64,6 +64,10 @@ module Devise
before_validation :strip_whitespace before_validation :strip_whitespace
end end
def self.required_fields(klass)
[]
end
# Check if the current object is valid for authentication. This method and # Check if the current object is valid for authentication. This method and
# find_for_authentication are the methods used in a Warden::Strategy to check # find_for_authentication are the methods used in a Warden::Strategy to check
# if a model should be signed in or not. # if a model should be signed in or not.

View file

@ -15,6 +15,10 @@ module Devise
module Omniauthable module Omniauthable
extend ActiveSupport::Concern extend ActiveSupport::Concern
def self.required_fields(klass)
[]
end
module ClassMethods module ClassMethods
Devise::Models.config(self, :omniauth_providers) Devise::Models.config(self, :omniauth_providers)
end end

View file

@ -5,6 +5,10 @@ module Devise
module Registerable module Registerable
extend ActiveSupport::Concern extend ActiveSupport::Concern
def self.required_fields(klass)
[]
end
module ClassMethods module ClassMethods
# A convenience method that receives both parameters and session to # A convenience method that receives both parameters and session to
# initialize a user. This can be used by OAuth, for example, to send # initialize a user. This can be used by OAuth, for example, to send

View file

@ -20,6 +20,10 @@ module Devise
module Timeoutable module Timeoutable
extend ActiveSupport::Concern extend ActiveSupport::Concern
def self.required_fields(klass)
[]
end
# Checks whether the user session has expired based on configured time. # Checks whether the user session has expired based on configured time.
def timedout?(last_access) def timedout?(last_access)
return false if remember_exists_and_not_expired? return false if remember_exists_and_not_expired?

View file

@ -0,0 +1,7 @@
require 'test_helper'
class AuthenticatableTest < ActiveSupport::TestCase
test 'required_fields should be an empty array' do
assert_equal Devise::Models::Validatable.required_fields(User), []
end
end

View file

@ -0,0 +1,7 @@
require 'test_helper'
class OmniauthableTest < ActiveSupport::TestCase
test 'required_fields should contain the fields that Devise uses' do
assert_same_content Devise::Models::Omniauthable.required_fields(User), []
end
end

View file

@ -0,0 +1,7 @@
require 'test_helper'
class RegisterableTest < ActiveSupport::TestCase
test 'required_fields should contain the fields that Devise uses' do
assert_same_content Devise::Models::Registerable.required_fields(User), []
end
end

View file

@ -39,4 +39,8 @@ class TimeoutableTest < ActiveSupport::TestCase
assert user.timedout?(6.minutes.ago) assert user.timedout?(6.minutes.ago)
end end
end end
test 'required_fields should contain the fields that Devise uses' do
assert_same_content Devise::Models::Timeoutable.required_fields(User), []
end
end end