mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
139b92495f
* TestCase: introduce declared setup and teardown callbacks. Pass a list of methods and an optional block to call before setup or after teardown. Setup callbacks are run in the order declared; teardown callbacks are run in reverse. [Jeremy Kemper] git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8570 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
47 lines
No EOL
1.8 KiB
Ruby
47 lines
No EOL
1.8 KiB
Ruby
require 'abstract_unit'
|
|
require 'fixtures/post'
|
|
require 'fixtures/comment'
|
|
require 'fixtures/project'
|
|
require 'fixtures/developer'
|
|
|
|
class AssociationsExtensionsTest < ActiveSupport::TestCase
|
|
fixtures :projects, :developers, :developers_projects, :comments, :posts
|
|
|
|
def test_extension_on_has_many
|
|
assert_equal comments(:more_greetings), posts(:welcome).comments.find_most_recent
|
|
end
|
|
|
|
def test_extension_on_habtm
|
|
assert_equal projects(:action_controller), developers(:david).projects.find_most_recent
|
|
end
|
|
|
|
def test_named_extension_on_habtm
|
|
assert_equal projects(:action_controller), developers(:david).projects_extended_by_name.find_most_recent
|
|
end
|
|
|
|
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
|
|
|
|
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
|
|
|
|
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
|
|
end
|
|
end |