1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Dynamic finder method like scoped_by_* create methods so that

method_missing is not hit next time. Adding a test for this
scenario.

Signed-off-by: José Valim <jose.valim@gmail.com>
This commit is contained in:
Neeraj Singh 2010-08-02 21:22:02 -04:00 committed by José Valim
parent 807239f5a1
commit db1c484c55

View file

@ -478,4 +478,10 @@ class DynamicScopeTest < ActiveRecord::TestCase
assert_equal Post.scoped_by_author_id(1).find(1), Post.find(1) assert_equal Post.scoped_by_author_id(1).find(1), Post.find(1)
assert_equal Post.scoped_by_author_id_and_title(1, "Welcome to the weblog").first, Post.find(:first, :conditions => { :author_id => 1, :title => "Welcome to the weblog"}) assert_equal Post.scoped_by_author_id_and_title(1, "Welcome to the weblog").first, Post.find(:first, :conditions => { :author_id => 1, :title => "Welcome to the weblog"})
end end
def test_dynamic_scope_should_create_methods_after_hitting_method_missing
assert Developer.methods.grep(/scoped_by_created_at/).blank?
Developer.scoped_by_created_at(nil)
assert Developer.methods.grep(/scoped_by_created_at/).present?
end
end end