2008-01-21 12:20:51 -05:00
|
|
|
require "cases/helper"
|
2008-01-18 02:30:42 -05:00
|
|
|
require 'models/post'
|
|
|
|
require 'models/comment'
|
|
|
|
require 'models/project'
|
|
|
|
require 'models/developer'
|
2005-11-03 04:06:42 -05:00
|
|
|
|
2008-01-21 12:20:51 -05:00
|
|
|
class AssociationsExtensionsTest < ActiveRecord::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
|
2008-01-18 02:30:42 -05:00
|
|
|
|
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
|
2007-09-17 17:19:44 -04:00
|
|
|
|
|
|
|
def test_named_extension_and_block_on_habtm
|
|
|
|
assert_equal projects(:action_controller), developers(:david).projects_extended_by_name_and_block.find_most_recent
|
|
|
|
assert_equal projects(:active_record), developers(:david).projects_extended_by_name_and_block.find_least_recent
|
|
|
|
end
|
|
|
|
|
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
|
2008-01-18 02:30:42 -05:00
|
|
|
end
|