mirror of
https://github.com/heartcombo/devise.git
synced 2022-11-09 12:18:31 -05:00
Changed message and refactored exception to use a initializer
This commit is contained in:
parent
a909bfaf85
commit
803e4f5524
2 changed files with 10 additions and 3 deletions
|
@ -1,6 +1,13 @@
|
|||
module Devise
|
||||
module Models
|
||||
class MissingAttribute < StandardError
|
||||
def initialize(attributes)
|
||||
@attributes = attributes
|
||||
end
|
||||
|
||||
def message
|
||||
"The following attribute(s) is (are) missing on your model: #{@attributes.join(", ")}"
|
||||
end
|
||||
end
|
||||
|
||||
# Creates configuration values for Devise and for the given module.
|
||||
|
@ -54,7 +61,7 @@ module Devise
|
|||
end
|
||||
|
||||
if failed_attributes.any?
|
||||
fail Devise::Models::MissingAttribute, "The following attributes are missing on your model: #{failed_attributes.join(", ")}"
|
||||
fail Devise::Models::MissingAttribute.new(failed_attributes)
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -138,7 +138,7 @@ class CheckFieldsTest < ActiveSupport::TestCase
|
|||
attr_accessor :encrypted_password
|
||||
end
|
||||
|
||||
assert_raise_with_message Devise::Models::MissingAttribute, "The following attributes are missing on your model: email" do
|
||||
assert_raise_with_message Devise::Models::MissingAttribute, "The following attribute(s) is (are) missing on your model: email" do
|
||||
Devise::Models.check_fields!(Clown)
|
||||
end
|
||||
end
|
||||
|
@ -153,7 +153,7 @@ class CheckFieldsTest < ActiveSupport::TestCase
|
|||
devise :database_authenticatable
|
||||
end
|
||||
|
||||
exception = assert_raise_with_message Devise::Models::MissingAttribute, "The following attributes are missing on your model: encrypted_password, email" do
|
||||
exception = assert_raise_with_message Devise::Models::MissingAttribute, "The following attribute(s) is (are) missing on your model: encrypted_password, email" do
|
||||
Devise::Models.check_fields!(Magician)
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue