From 83c1934003740ed01c618a8943457a0df53e2adb Mon Sep 17 00:00:00 2001 From: mattbauer Date: Sun, 21 Jun 2009 17:35:04 +0100 Subject: Ensure hm:t#create respects source associations hash conditions [#2090 state:resolved] Signed-off-by: Pratik Naik --- .../test/cases/associations/has_many_through_associations_test.rb | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'activerecord/test/cases/associations') diff --git a/activerecord/test/cases/associations/has_many_through_associations_test.rb b/activerecord/test/cases/associations/has_many_through_associations_test.rb index 4254badef2..7a4712d7c8 100644 --- a/activerecord/test/cases/associations/has_many_through_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_through_associations_test.rb @@ -157,6 +157,12 @@ class HasManyThroughAssociationsTest < ActiveRecord::TestCase assert_equal peeps + 1, posts(:thinking).people.count end + def test_associate_with_create_with_through_having_conditions + impatient_people = posts(:thinking).impatient_people.count + posts(:thinking).impatient_people.create!(:first_name => 'foo') + assert_equal impatient_people + 1, posts(:thinking).impatient_people.count + end + def test_associate_with_create_exclamation_and_no_options peeps = posts(:thinking).people.count posts(:thinking).people.create!(:first_name => 'foo') -- cgit v1.2.3 From 4851ca9e13a4317342df02ae25b1929340523f7a Mon Sep 17 00:00:00 2001 From: Patrick Joyce Date: Sun, 21 Jun 2009 22:07:23 +0100 Subject: Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [#2118 state:resolved] Signed-off-by: Pratik Naik --- .../cases/associations/has_and_belongs_to_many_associations_test.rb | 5 +++++ activerecord/test/cases/associations/has_many_associations_test.rb | 5 +++++ 2 files changed, 10 insertions(+) (limited to 'activerecord/test/cases/associations') diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 8dc95806b9..9dbbd01aa1 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -803,6 +803,11 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_equal 1, developer.projects.count end + def test_count_with_finder_sql + assert_equal 3, projects(:active_record).developers_with_finder_sql.count + assert_equal 3, projects(:active_record).developers_with_multiline_finder_sql.count + end + def test_association_proxy_transaction_method_starts_transaction_in_association_class Post.expects(:transaction) Category.find(:first).posts.transaction do diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index d99424f9cd..15919e2289 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -163,6 +163,11 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 0, Firm.find(:first).no_clients_using_counter_sql.size end + def test_counting_using_finder_sql + assert_equal 2, Firm.find(4).clients_using_sql.count + assert_equal 2, Firm.find(4).clients_using_multiline_sql.count + end + def test_belongs_to_sanity c = Client.new assert_nil c.firm -- cgit v1.2.3 From 80f1f863cd0f9cba89079511282de5710a2e1832 Mon Sep 17 00:00:00 2001 From: Yehuda Katz + Carl Lerche Date: Mon, 22 Jun 2009 12:04:02 -0700 Subject: Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [#2118 state:resolved]" This reverts commit 4851ca9e13a4317342df02ae25b1929340523f7a. The tests do not pass for postgresql. --- .../cases/associations/has_and_belongs_to_many_associations_test.rb | 5 ----- activerecord/test/cases/associations/has_many_associations_test.rb | 5 ----- 2 files changed, 10 deletions(-) (limited to 'activerecord/test/cases/associations') diff --git a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb index 9dbbd01aa1..8dc95806b9 100644 --- a/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb @@ -803,11 +803,6 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase assert_equal 1, developer.projects.count end - def test_count_with_finder_sql - assert_equal 3, projects(:active_record).developers_with_finder_sql.count - assert_equal 3, projects(:active_record).developers_with_multiline_finder_sql.count - end - def test_association_proxy_transaction_method_starts_transaction_in_association_class Post.expects(:transaction) Category.find(:first).posts.transaction do diff --git a/activerecord/test/cases/associations/has_many_associations_test.rb b/activerecord/test/cases/associations/has_many_associations_test.rb index 15919e2289..d99424f9cd 100644 --- a/activerecord/test/cases/associations/has_many_associations_test.rb +++ b/activerecord/test/cases/associations/has_many_associations_test.rb @@ -163,11 +163,6 @@ class HasManyAssociationsTest < ActiveRecord::TestCase assert_equal 0, Firm.find(:first).no_clients_using_counter_sql.size end - def test_counting_using_finder_sql - assert_equal 2, Firm.find(4).clients_using_sql.count - assert_equal 2, Firm.find(4).clients_using_multiline_sql.count - end - def test_belongs_to_sanity c = Client.new assert_nil c.firm -- cgit v1.2.3