diff --git a/lib/devise/models/authenticatable.rb b/lib/devise/models/authenticatable.rb index 918ab181..3a81d315 100644 --- a/lib/devise/models/authenticatable.rb +++ b/lib/devise/models/authenticatable.rb @@ -64,6 +64,10 @@ module Devise before_validation :strip_whitespace end + def self.required_fields(klass) + [] + end + # 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 # if a model should be signed in or not. diff --git a/lib/devise/models/omniauthable.rb b/lib/devise/models/omniauthable.rb index d806f79f..d1a2d4ae 100644 --- a/lib/devise/models/omniauthable.rb +++ b/lib/devise/models/omniauthable.rb @@ -15,6 +15,10 @@ module Devise module Omniauthable extend ActiveSupport::Concern + def self.required_fields(klass) + [] + end + module ClassMethods Devise::Models.config(self, :omniauth_providers) end diff --git a/lib/devise/models/registerable.rb b/lib/devise/models/registerable.rb index f895beaf..1f10dd2e 100644 --- a/lib/devise/models/registerable.rb +++ b/lib/devise/models/registerable.rb @@ -5,6 +5,10 @@ module Devise module Registerable extend ActiveSupport::Concern + def self.required_fields(klass) + [] + end + module ClassMethods # A convenience method that receives both parameters and session to # initialize a user. This can be used by OAuth, for example, to send diff --git a/lib/devise/models/timeoutable.rb b/lib/devise/models/timeoutable.rb index 176ec0a3..d595323c 100644 --- a/lib/devise/models/timeoutable.rb +++ b/lib/devise/models/timeoutable.rb @@ -20,6 +20,10 @@ module Devise module Timeoutable extend ActiveSupport::Concern + def self.required_fields(klass) + [] + end + # Checks whether the user session has expired based on configured time. def timedout?(last_access) return false if remember_exists_and_not_expired? diff --git a/test/models/authenticatable_test.rb b/test/models/authenticatable_test.rb new file mode 100644 index 00000000..132be644 --- /dev/null +++ b/test/models/authenticatable_test.rb @@ -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 \ No newline at end of file diff --git a/test/models/omniauthable_test.rb b/test/models/omniauthable_test.rb new file mode 100644 index 00000000..13a89a59 --- /dev/null +++ b/test/models/omniauthable_test.rb @@ -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 diff --git a/test/models/registerable_test.rb b/test/models/registerable_test.rb new file mode 100644 index 00000000..fe157289 --- /dev/null +++ b/test/models/registerable_test.rb @@ -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 diff --git a/test/models/timeoutable_test.rb b/test/models/timeoutable_test.rb index cb2ee701..9dc93e0c 100644 --- a/test/models/timeoutable_test.rb +++ b/test/models/timeoutable_test.rb @@ -39,4 +39,8 @@ class TimeoutableTest < ActiveSupport::TestCase assert user.timedout?(6.minutes.ago) end end + + test 'required_fields should contain the fields that Devise uses' do + assert_same_content Devise::Models::Timeoutable.required_fields(User), [] + end end