2005-11-03 04:06:42 -05:00
|
|
|
require 'abstract_unit'
|
2005-11-04 14:39:50 -05:00
|
|
|
require 'fixtures/post'
|
|
|
|
require 'fixtures/comment'
|
2005-11-03 04:06:42 -05:00
|
|
|
require 'fixtures/project'
|
|
|
|
require 'fixtures/developer'
|
|
|
|
|
|
|
|
class AssociationsExtensionsTest < Test::Unit::TestCase
|
2005-11-06 14:25:58 -05:00
|
|
|
fixtures :projects, :developers, :developers_projects, :comments, :posts
|
2005-11-03 04:06:42 -05:00
|
|
|
|
2005-11-06 14:05:42 -05:00
|
|
|
def test_extension_on_has_many
|
|
|
|
assert_equal comments(:more_greetings), posts(:welcome).comments.find_most_recent
|
|
|
|
end
|
|
|
|
|
2005-11-03 04:06:42 -05:00
|
|
|
def test_extension_on_habtm
|
|
|
|
assert_equal projects(:action_controller), developers(:david).projects.find_most_recent
|
|
|
|
end
|
2005-11-06 14:05:42 -05:00
|
|
|
|
|
|
|
def test_named_extension_on_habtm
|
|
|
|
assert_equal projects(:action_controller), developers(:david).projects_extended_by_name.find_most_recent
|
|
|
|
end
|
2006-04-10 21:10:42 -04:00
|
|
|
|
|
|
|
def test_named_two_extensions_on_habtm
|
|
|
|
assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_twice.find_most_recent
|
|
|
|
assert_equal projects(:active_record), developers(:david).projects_extended_by_name_twice.find_least_recent
|
|
|
|
end
|
2005-11-03 04:06:42 -05:00
|
|
|
|
2005-11-06 14:05:42 -05:00
|
|
|
def test_marshalling_extensions
|
|
|
|
david = developers(:david)
|
|
|
|
assert_equal projects(:action_controller), david.projects.find_most_recent
|
|
|
|
|
|
|
|
david = Marshal.load(Marshal.dump(david))
|
|
|
|
assert_equal projects(:action_controller), david.projects.find_most_recent
|
|
|
|
end
|
|
|
|
|
|
|
|
def test_marshalling_named_extensions
|
|
|
|
david = developers(:david)
|
|
|
|
assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent
|
|
|
|
|
|
|
|
david = Marshal.load(Marshal.dump(david))
|
|
|
|
assert_equal projects(:action_controller), david.projects_extended_by_name.find_most_recent
|
2005-11-03 04:06:42 -05:00
|
|
|
end
|
|
|
|
end
|