Permalink
Browse files

Fix example for Rails 3.1

Avoid using has_key? as it is not available on 3.1.
  • Loading branch information...
1 parent 76a5dd2 commit 77f29e245309097a143ca1cb05e9de87eae42dd8 @xymbol xymbol committed May 17, 2012
Showing with 2 additions and 2 deletions.
  1. +2 −2 test/reserved_test.rb
View
@@ -11,7 +11,7 @@ class Journalist < ActiveRecord::Base
after_validation :move_friendly_id_error_to_name
def move_friendly_id_error_to_name
- errors.add :name, *errors.delete(:friendly_id) if errors.has_key?(:friendly_id)
+ errors.add :name, *errors.delete(:friendly_id) if errors[:friendly_id].present?
end
end
@@ -32,7 +32,7 @@ def model_class
record.errors.add :name, "xxx"
record.errors.add :friendly_id, "yyy"
record.move_friendly_id_error_to_name
- assert record.errors.get(:name) && !record.errors.get(:friendly_id)
+ assert record.errors[:name].present? && record.errors[:friendly_id].blank?
assert_equal 2, record.errors.count
end
end

0 comments on commit 77f29e2

Please sign in to comment.