diff options
author | Jeremy Friesen <jeremy.n.friesen@gmail.com> | 2011-05-16 11:55:24 -0400 |
---|---|---|
committer | Jeremy Friesen <jeremy.n.friesen@gmail.com> | 2011-05-24 13:52:48 -0400 |
commit | f2a0dfc2985c008a618e1616f6cf9a4c54098c33 (patch) | |
tree | ae344124052201dce41dad55860b65b2916142a1 /activerecord/test/cases | |
parent | ae323a51f1dcf5529f34927cb91693a993416b07 (diff) | |
download | rails-f2a0dfc2985c008a618e1616f6cf9a4c54098c33.tar.gz rails-f2a0dfc2985c008a618e1616f6cf9a4c54098c33.tar.bz2 rails-f2a0dfc2985c008a618e1616f6cf9a4c54098c33.zip |
Addresses an inconsistency in the ActiveRecord::Base.method_missing handling of dynamic finder methods and the passing of the &block parameter for :find_by_attributes.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r-- | activerecord/test/cases/relations_test.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/activerecord/test/cases/relations_test.rb b/activerecord/test/cases/relations_test.rb index fc9df8c7a3..d95acdc39b 100644 --- a/activerecord/test/cases/relations_test.rb +++ b/activerecord/test/cases/relations_test.rb @@ -372,6 +372,15 @@ class RelationTest < ActiveRecord::TestCase assert_equal Post.find(1).last_comment, post.last_comment end + def test_dynamic_find_by_attributes_should_yield_found_object + david = authors(:david) + yielded_value = nil + Author.find_by_name(david.name) do |author| + yielded_value = author + end + assert_equal david, yielded_value + end + def test_dynamic_find_by_attributes david = authors(:david) author = Author.preload(:taggings).find_by_id(david.id) |