Upgrade to Rails 2.0.2
Upgraded to Rails 2.0.2, except that we maintain vendor/rails/actionpack/lib/action_controller/routing.rb from Rail 1.2.6 (at least for now), so that Routes don't change. We still get to enjoy Rails's many new features. Also fixed a bug in Chunk-handling: disable WikiWord processing in tags (for real this time).
This commit is contained in:
parent
0f6889e09f
commit
6873fc8026
1083 changed files with 52810 additions and 41058 deletions
48
vendor/rails/activeresource/test/base_errors_test.rb
vendored
Normal file
48
vendor/rails/activeresource/test/base_errors_test.rb
vendored
Normal file
|
@ -0,0 +1,48 @@
|
|||
require "#{File.dirname(__FILE__)}/abstract_unit"
|
||||
require "fixtures/person"
|
||||
|
||||
class BaseErrorsTest < Test::Unit::TestCase
|
||||
def setup
|
||||
ActiveResource::HttpMock.respond_to do |mock|
|
||||
mock.post "/people.xml", {}, "<?xml version=\"1.0\" encoding=\"UTF-8\"?><errors><error>Age can't be blank</error><error>Name can't be blank</error><error>Name must start with a letter</error><error>Person quota full for today.</error></errors>", 422
|
||||
end
|
||||
@person = Person.new(:name => '', :age => '')
|
||||
assert_equal @person.save, false
|
||||
end
|
||||
|
||||
def test_should_mark_as_invalid
|
||||
assert !@person.valid?
|
||||
end
|
||||
|
||||
def test_should_parse_xml_errors
|
||||
assert_kind_of ActiveResource::Errors, @person.errors
|
||||
assert_equal 4, @person.errors.size
|
||||
end
|
||||
|
||||
def test_should_parse_errors_to_individual_attributes
|
||||
assert @person.errors.invalid?(:name)
|
||||
assert_equal "can't be blank", @person.errors.on(:age)
|
||||
assert_equal ["can't be blank", "must start with a letter"], @person.errors[:name]
|
||||
assert_equal "Person quota full for today.", @person.errors.on_base
|
||||
end
|
||||
|
||||
def test_should_iterate_over_errors
|
||||
errors = []
|
||||
@person.errors.each { |attribute, message| errors << [attribute, message] }
|
||||
assert errors.include?(["name", "can't be blank"])
|
||||
end
|
||||
|
||||
def test_should_iterate_over_full_errors
|
||||
errors = []
|
||||
@person.errors.each_full { |message| errors << message }
|
||||
assert errors.include?("Name can't be blank")
|
||||
end
|
||||
|
||||
def test_should_format_full_errors
|
||||
full = @person.errors.full_messages
|
||||
assert full.include?("Age can't be blank")
|
||||
assert full.include?("Name can't be blank")
|
||||
assert full.include?("Name must start with a letter")
|
||||
assert full.include?("Person quota full for today.")
|
||||
end
|
||||
end
|
Loading…
Add table
Add a link
Reference in a new issue