Rails3: test: replace deprecated Errors#on to Errors#[] and join with to_s at test/unit/wiki_page_test.rb

On Rails2, Errors#[] returns single error if one error raises.
But, on Rails3, Errors#[] always returns the array.

git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8134 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
Toshi MARUYAMA 2011-12-09 05:55:32 +00:00
parent 63d27a5389
commit caf9edf2c1
1 changed files with 6 additions and 4 deletions

View File

@ -85,16 +85,18 @@ class WikiPageTest < ActiveSupport::TestCase
# A page that doesn't exist
page.parent_title = 'Unknown title'
assert !page.save
assert_equal I18n.translate('activerecord.errors.messages.invalid'), page.errors.on(:parent_title)
assert_equal I18n.translate('activerecord.errors.messages.invalid'),
page.errors[:parent_title].to_s
# A child page
page.parent_title = 'Page_with_an_inline_image'
assert !page.save
assert_equal I18n.translate('activerecord.errors.messages.circular_dependency'), page.errors.on(:parent_title)
assert_equal I18n.translate('activerecord.errors.messages.circular_dependency'),
page.errors[:parent_title].to_s
# The page itself
page.parent_title = 'CookBook_documentation'
assert !page.save
assert_equal I18n.translate('activerecord.errors.messages.circular_dependency'), page.errors.on(:parent_title)
assert_equal I18n.translate('activerecord.errors.messages.circular_dependency'),
page.errors[:parent_title].to_s
page.parent_title = 'Another_page'
assert page.save
end