From 58edaaad0bc32a4b190329dcc8fb0e3bb1869c46 Mon Sep 17 00:00:00 2001 From: Michael Koziarski Date: Wed, 27 Dec 2006 20:35:19 +0000 Subject: Ensure dynamic finders are anchored to the beginning of the method name to prevent git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@5795 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activerecord/test/finder_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'activerecord/test') diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb index cf2dfcbb24..d31d859b44 100644 --- a/activerecord/test/finder_test.rb +++ b/activerecord/test/finder_test.rb @@ -293,6 +293,13 @@ class FinderTest < Test::Unit::TestCase def test_find_by_one_missing_attribute assert_raises(NoMethodError) { Topic.find_by_undertitle("The First Topic!") } end + + def test_find_by_invalid_method_syntax + assert_raises(NoMethodError) { Topic.fail_to_find_by_title("The First Topic") } + assert_raises(NoMethodError) { Topic.find_by_title?("The First Topic") } + assert_raises(NoMethodError) { Topic.fail_to_find_or_create_by_title("Nonexistent Title") } + assert_raises(NoMethodError) { Topic.find_or_create_by_title?("Nonexistent Title") } + end def test_find_by_two_attributes assert_equal topics(:first), Topic.find_by_title_and_author_name("The First Topic", "David") -- cgit v1.2.3