0
@@ -197,11 +197,11 @@ class FinderTest < ActiveRecord::TestCase
0
first = Topic.find(:first, :conditions => "title = 'The First Topic!'")
0
assert_equal topics(:second).title, Topic.first(:conditions => "title = 'The Second Topic of the day'").title
0
assert_nil Topic.first(:conditions => "title = 'The Second Topic of the day!'")
0
@@ -418,7 +418,7 @@ class FinderTest < ActiveRecord::TestCase
0
def test_named_bind_variables
0
assert_equal '1', bind(':a', :a => 1) # ' ruby-mode
0
assert_equal '1 1', bind(':a :a', :a => 1) # ' ruby-mode
0
assert_nothing_raised { bind("'+00:00'", :foo => "bar") }
0
assert_kind_of Firm, Company.find(:first, :conditions => ["name = :name", { :name => "37signals" }])
0
@@ -589,6 +589,38 @@ class FinderTest < ActiveRecord::TestCase
0
assert_nil Topic.find_by_title_and_author_name("The First Topic", "Mary")
0
+ def test_find_last_by_one_attribute
0
+ assert_equal Topic.last, Topic.find_last_by_title(Topic.last.title)
0
+ assert_nil Topic.find_last_by_title("A title with no matches")
0
+ def test_find_last_by_one_attribute_caches_dynamic_finder
0
+ # ensure this test can run independently of order
0
+ class << Topic; self; end.send(:remove_method, :find_last_by_title) if Topic.public_methods.any? { |m| m.to_s == 'find_last_by_title' }
0
+ assert !Topic.public_methods.any? { |m| m.to_s == 'find_last_by_title' }
0
+ t = Topic.find_last_by_title(Topic.last)
0
+ assert Topic.public_methods.any? { |m| m.to_s == 'find_last_by_title' }
0
+ def test_find_last_by_invalid_method_syntax
0
+ assert_raises(NoMethodError) { Topic.fail_to_find_last_by_title("The First Topic") }
0
+ assert_raises(NoMethodError) { Topic.find_last_by_title?("The First Topic") }
0
+ def test_find_last_by_one_attribute_with_several_options
0
+ assert_equal accounts(:signals37), Account.find_last_by_credit_limit(50, :order => 'id DESC', :conditions => ['id != ?', 3])
0
+ def test_find_last_by_one_missing_attribute
0
+ assert_raises(NoMethodError) { Topic.find_last_by_undertitle("The Last Topic!") }
0
+ def test_find_last_by_two_attributes
0
+ assert_equal topic, Topic.find_last_by_title_and_author_name(topic.title, topic.author_name)
0
+ assert_nil Topic.find_last_by_title_and_author_name(topic.title, "Anonymous")
0
def test_find_all_by_one_attribute
0
topics = Topic.find_all_by_content("Have a nice day")
0
assert_equal 2, topics.size
0
@@ -782,7 +814,7 @@ class FinderTest < ActiveRecord::TestCase
0
def test_dynamic_find_or_initialize_from_one_attribute_caches_method
0
class << Company; self; end.send(:remove_method, :find_or_initialize_by_name) if Company.public_methods.any? { |m| m.to_s == 'find_or_initialize_by_name' }
0
assert !Company.public_methods.any? { |m| m.to_s == 'find_or_initialize_by_name' }