From 295f0966a0fa428df4d0d0124e720fe2f44bbcd2 Mon Sep 17 00:00:00 2001 From: Amos King Date: Thu, 29 May 2008 15:01:33 -0700 Subject: [PATCH] tests for associations first and last methods being passed a hash ticket #275 --- activerecord/test/cases/associations_test.rb | 20 ++++++++++++++++++++ 1 files changed, 20 insertions(+), 0 deletions(-) diff --git a/activerecord/test/cases/associations_test.rb b/activerecord/test/cases/associations_test.rb index 59349dd..b6064a6 100755 --- a/activerecord/test/cases/associations_test.rb +++ b/activerecord/test/cases/associations_test.rb @@ -48,6 +48,26 @@ class AssociationsTest < ActiveRecord::TestCase assert_equal [reader], person.readers.find(:all) end + def test_first_on_association_with_conditions + firm = Firm.new("name" => "A New Firm, Inc") + firm.save + client = Client.new("name" => "TheClient.com", "firm_id" => firm.id) + client.save + client2 = Client.new("name" => "TheClient2.com", "firm_id" => firm.id) + client2.save + assert (firm.clients.first :conditions => { :name => 'TheClient2.com' }) == client2 + end + + def test_last_on_association_with_conditions + firm = Firm.new("name" => "A New Firm, Inc") + firm.save + client = Client.new("name" => "TheClient.com", "firm_id" => firm.id) + client.save + client2 = Client.new("name" => "TheClient2.com", "firm_id" => firm.id) + client2.save + assert (firm.clients.last :conditions => { :name => 'TheClient2.com' }) == client2 + end + def test_force_reload firm = Firm.new("name" => "A New Firm, Inc") firm.save -- 1.5.5.1.316.g377d9