aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases
diff options
context:
space:
mode:
authorPratik Naik <pratiknaik@gmail.com>2009-06-30 23:55:09 +0100
committerPratik Naik <pratiknaik@gmail.com>2009-07-01 00:02:00 +0100
commit45e6f19925f23c3db257c15371d8f512cca843cd (patch)
tree64b056dc3650dded78d50f35399f23e1edf122f9 /activerecord/test/cases
parentdb3de78a83379ab2a58e0d29fb10622b813a4d44 (diff)
downloadrails-45e6f19925f23c3db257c15371d8f512cca843cd.tar.gz
rails-45e6f19925f23c3db257c15371d8f512cca843cd.tar.bz2
rails-45e6f19925f23c3db257c15371d8f512cca843cd.zip
Revert "Revert "Generate proper :counter_sql from :finder_sql when there is a newline character immediately following 'SELECT' [#2118 state:resolved]""
This reverts commit 80f1f863cd0f9cba89079511282de5710a2e1832. The feature doesn't work on Postgres, so don't test it on Postgres. Also, Postgres compatibility is irrelevant to the ticket/patch in question.
Diffstat (limited to 'activerecord/test/cases')
-rw-r--r--activerecord/test/cases/associations/has_and_belongs_to_many_associations_test.rb7
-rw-r--r--activerecord/test/cases/associations/has_many_associations_test.rb5
-rwxr-xr-xactiverecord/test/cases/base_test.rb6
-rw-r--r--activerecord/test/cases/calculations_test.rb4
-rw-r--r--activerecord/test/cases/finder_test.rb4
-rw-r--r--activerecord/test/cases/inheritance_test.rb4
-rw-r--r--activerecord/test/cases/reflection_test.rb4
7 files changed, 23 insertions, 11 deletions
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..14b96caaae 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,13 @@ class HasAndBelongsToManyAssociationsTest < ActiveRecord::TestCase
assert_equal 1, developer.projects.count
end
+ unless current_adapter?(:PostgreSQLAdapter)
+ 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
+ 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
diff --git a/activerecord/test/cases/base_test.rb b/activerecord/test/cases/base_test.rb
index 96270118d8..0f3f6e41a5 100755
--- a/activerecord/test/cases/base_test.rb
+++ b/activerecord/test/cases/base_test.rb
@@ -599,9 +599,9 @@ class BasicsTest < ActiveRecord::TestCase
end
def test_destroy_many
- assert_equal 3, Client.count
- Client.destroy([2, 3])
- assert_equal 1, Client.count
+ assert_difference('Client.count', -2) do
+ Client.destroy([2, 3])
+ end
end
def test_delete_many
diff --git a/activerecord/test/cases/calculations_test.rb b/activerecord/test/cases/calculations_test.rb
index fd455e0864..75f52dfa4a 100644
--- a/activerecord/test/cases/calculations_test.rb
+++ b/activerecord/test/cases/calculations_test.rb
@@ -203,7 +203,7 @@ class CalculationsTest < ActiveRecord::TestCase
c = Company.count(:all, :group => "UPPER(#{QUOTED_TYPE})")
assert_equal 2, c[nil]
assert_equal 1, c['DEPENDENTFIRM']
- assert_equal 3, c['CLIENT']
+ assert_equal 4, c['CLIENT']
assert_equal 2, c['FIRM']
end
@@ -211,7 +211,7 @@ class CalculationsTest < ActiveRecord::TestCase
c = Company.count(:all, :group => "UPPER(companies.#{QUOTED_TYPE})")
assert_equal 2, c[nil]
assert_equal 1, c['DEPENDENTFIRM']
- assert_equal 3, c['CLIENT']
+ assert_equal 4, c['CLIENT']
assert_equal 2, c['FIRM']
end
diff --git a/activerecord/test/cases/finder_test.rb b/activerecord/test/cases/finder_test.rb
index 037b67ec84..d8f5695a0f 100644
--- a/activerecord/test/cases/finder_test.rb
+++ b/activerecord/test/cases/finder_test.rb
@@ -1044,8 +1044,8 @@ class FinderTest < ActiveRecord::TestCase
end
def test_select_values
- assert_equal ["1","2","3","4","5","6","7","8","9"], Company.connection.select_values("SELECT id FROM companies ORDER BY id").map! { |i| i.to_s }
- assert_equal ["37signals","Summit","Microsoft", "Flamboyant Software", "Ex Nihilo", "RailsCore", "Leetsoft", "Jadedpixel", "Odegy"], Company.connection.select_values("SELECT name FROM companies ORDER BY id")
+ assert_equal ["1","2","3","4","5","6","7","8","9", "10"], Company.connection.select_values("SELECT id FROM companies ORDER BY id").map! { |i| i.to_s }
+ assert_equal ["37signals","Summit","Microsoft", "Flamboyant Software", "Ex Nihilo", "RailsCore", "Leetsoft", "Jadedpixel", "Odegy", "Ex Nihilo Part Deux"], Company.connection.select_values("SELECT name FROM companies ORDER BY id")
end
def test_select_rows
diff --git a/activerecord/test/cases/inheritance_test.rb b/activerecord/test/cases/inheritance_test.rb
index eae5a60829..167d3abad9 100644
--- a/activerecord/test/cases/inheritance_test.rb
+++ b/activerecord/test/cases/inheritance_test.rb
@@ -112,9 +112,9 @@ class InheritanceTest < ActiveRecord::TestCase
end
def test_inheritance_condition
- assert_equal 9, Company.count
+ assert_equal 10, Company.count
assert_equal 2, Firm.count
- assert_equal 3, Client.count
+ assert_equal 4, Client.count
end
def test_alt_inheritance_condition
diff --git a/activerecord/test/cases/reflection_test.rb b/activerecord/test/cases/reflection_test.rb
index d861b5bb24..194d5e9dff 100644
--- a/activerecord/test/cases/reflection_test.rb
+++ b/activerecord/test/cases/reflection_test.rb
@@ -176,8 +176,8 @@ class ReflectionTest < ActiveRecord::TestCase
def test_reflection_of_all_associations
# FIXME these assertions bust a lot
- assert_equal 28, Firm.reflect_on_all_associations.size
- assert_equal 21, Firm.reflect_on_all_associations(:has_many).size
+ assert_equal 29, Firm.reflect_on_all_associations.size
+ assert_equal 22, Firm.reflect_on_all_associations(:has_many).size
assert_equal 7, Firm.reflect_on_all_associations(:has_one).size
assert_equal 0, Firm.reflect_on_all_associations(:belongs_to).size
end