summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/models/identity.rb10
-rw-r--r--app/models/user.rb6
-rw-r--r--test/unit/identity_test.rb1
3 files changed, 10 insertions, 7 deletions
diff --git a/app/models/identity.rb b/app/models/identity.rb
index 25be971..f2727c8 100644
--- a/app/models/identity.rb
+++ b/app/models/identity.rb
@@ -141,15 +141,17 @@ class Identity < CouchRest::Model::Base
def address_local_email
return if address.valid? #this ensures it is a valid local email address
- # we only hand on the first error for now.
- self.errors.add(:address, address.errors.messages.values.first)
+ address.errors.each do |attribute, error|
+ self.errors.add(:address, error)
+ end
end
def destination_email
return if destination.nil? # this identity is disabled
return if destination.valid? # this ensures it is Email
- # we only hand on the first error for now.
- self.errors.add(:destination, destination.errors.messages.values.first)
+ destination.errors.each do |attribute, error|
+ self.errors.add(:destination, error)
+ end
end
end
diff --git a/app/models/user.rb b/app/models/user.rb
index 33508b5..84a795e 100644
--- a/app/models/user.rb
+++ b/app/models/user.rb
@@ -167,10 +167,10 @@ class User < CouchRest::Model::Base
##
def identity_is_valid
- refresh_identity
return if identity.valid?
- # hand on the first error only for now
- self.errors.add(:login, identity.errors.messages.values.first)
+ identity.errors.each do |attribute, error|
+ self.errors.add(:login, error)
+ end
end
def password
diff --git a/test/unit/identity_test.rb b/test/unit/identity_test.rb
index 9c938f8..54c0657 100644
--- a/test/unit/identity_test.rb
+++ b/test/unit/identity_test.rb
@@ -107,6 +107,7 @@ class IdentityTest < ActiveSupport::TestCase
other_user = find_record :user
taken = Identity.build_for other_user, address: id.address
assert !taken.valid?
+ assert_equal ["has already been taken"], taken.errors[:address]
Identity.destroy_all_disabled
end