1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00
rails--rails/activerecord/test/aggregations_test.rb
David Heinemeier Hansson db045dbbf6 Initial
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2004-11-24 01:04:44 +00:00

34 lines
No EOL
1 KiB
Ruby

require 'abstract_unit'
# require File.dirname(__FILE__) + '/../dev-utils/eval_debugger'
require 'fixtures/customer'
class AggregationsTest < Test::Unit::TestCase
def setup
@customers = create_fixtures "customers"
@david = Customer.find(1)
end
def test_find_single_value_object
assert_equal 50, @david.balance.amount
assert_kind_of Money, @david.balance
assert_equal 300, @david.balance.exchange_to("DKK").amount
end
def test_find_multiple_value_object
assert_equal @customers["david"]["address_street"], @david.address.street
assert(
@david.address.close_to?(Address.new("Different Street", @customers["david"]["address_city"], @customers["david"]["address_country"]))
)
end
def test_change_single_value_object
@david.balance = Money.new(100)
@david.save
assert_equal 100, Customer.find(1).balance.amount
end
def test_immutable_value_objects
@david.balance = Money.new(100)
assert_raises(TypeError) { @david.balance.instance_eval { @amount = 20 } }
end
end