aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
diff options
context:
space:
mode:
Diffstat (limited to 'activerecord/test')
-rwxr-xr-xactiverecord/test/associations_test.rb4
-rwxr-xr-xactiverecord/test/base_test.rb2
-rw-r--r--activerecord/test/calculations_test.rb12
-rwxr-xr-xactiverecord/test/deprecated_finder_test.rb6
-rw-r--r--activerecord/test/finder_test.rb6
-rw-r--r--activerecord/test/method_scoping_test.rb4
6 files changed, 24 insertions, 10 deletions
diff --git a/activerecord/test/associations_test.rb b/activerecord/test/associations_test.rb
index 5e9a39873d..b843f5bdf5 100755
--- a/activerecord/test/associations_test.rb
+++ b/activerecord/test/associations_test.rb
@@ -395,7 +395,9 @@ class HasManyAssociationsTest < Test::Unit::TestCase
end
def test_counting_with_single_conditions
- assert_equal 2, Firm.find(:first).plain_clients.count('1=1')
+ assert_deprecated 'count' do
+ assert_equal 2, Firm.find(:first).plain_clients.count('1=1')
+ end
end
def test_counting_with_single_hash
diff --git a/activerecord/test/base_test.rb b/activerecord/test/base_test.rb
index c1dc89a611..055f5e8670 100755
--- a/activerecord/test/base_test.rb
+++ b/activerecord/test/base_test.rb
@@ -1159,7 +1159,7 @@ class BasicsTest < Test::Unit::TestCase
def test_count_with_join
res = Post.count_by_sql "SELECT COUNT(*) FROM posts LEFT JOIN comments ON posts.id=comments.post_id WHERE posts.#{QUOTED_TYPE} = 'Post'"
res2 = nil
- assert_nothing_raised do
+ assert_deprecated 'count' do
res2 = Post.count("posts.#{QUOTED_TYPE} = 'Post'",
"LEFT JOIN comments ON posts.id=comments.post_id")
end
diff --git a/activerecord/test/calculations_test.rb b/activerecord/test/calculations_test.rb
index 397b7a9026..23c45f8637 100644
--- a/activerecord/test/calculations_test.rb
+++ b/activerecord/test/calculations_test.rb
@@ -196,4 +196,16 @@ class CalculationsTest < Test::Unit::TestCase
assert_equal 6, Account.count(:distinct => true, :include => :firm)
assert_equal 4, Account.count(:distinct => true, :include => :firm, :select => :credit_limit)
end
+
+ def test_deprecated_count_with_string_parameters
+ assert_deprecated('count') { Account.count('credit_limit > 50') }
+ end
+
+ def test_count_with_no_parameters_isnt_deprecated
+ assert_not_deprecated { Account.count }
+ end
+
+ def test_count_with_too_many_parameters_raises
+ assert_raise(ArgumentError) { Account.count(1, 2, 3) }
+ end
end
diff --git a/activerecord/test/deprecated_finder_test.rb b/activerecord/test/deprecated_finder_test.rb
index fa56e8ee04..796e46f8c2 100755
--- a/activerecord/test/deprecated_finder_test.rb
+++ b/activerecord/test/deprecated_finder_test.rb
@@ -88,9 +88,9 @@ class DeprecatedFinderTest < Test::Unit::TestCase
end
def test_count
- assert_equal(0, Entrant.count("id > 3"))
- assert_equal(1, Entrant.count(["id > ?", 2]))
- assert_equal(2, Entrant.count(["id > ?", 1]))
+ assert_equal(0, Entrant.count(:conditions => "id > 3"))
+ assert_equal(1, Entrant.count(:conditions => ["id > ?", 2]))
+ assert_equal(2, Entrant.count(:conditions => ["id > ?", 1]))
end
def test_count_by_sql
diff --git a/activerecord/test/finder_test.rb b/activerecord/test/finder_test.rb
index bd72348916..ebc21b5e0c 100644
--- a/activerecord/test/finder_test.rb
+++ b/activerecord/test/finder_test.rb
@@ -249,9 +249,9 @@ class FinderTest < Test::Unit::TestCase
end
def test_count
- assert_equal(0, Entrant.count("id > 3"))
- assert_equal(1, Entrant.count(["id > ?", 2]))
- assert_equal(2, Entrant.count(["id > ?", 1]))
+ assert_equal(0, Entrant.count(:conditions => "id > 3"))
+ assert_equal(1, Entrant.count(:conditions => ["id > ?", 2]))
+ assert_equal(2, Entrant.count(:conditions => ["id > ?", 1]))
end
def test_count_by_sql
diff --git a/activerecord/test/method_scoping_test.rb b/activerecord/test/method_scoping_test.rb
index bceb3869a6..ee4a52df1d 100644
--- a/activerecord/test/method_scoping_test.rb
+++ b/activerecord/test/method_scoping_test.rb
@@ -57,7 +57,7 @@ class MethodScopingTest < Test::Unit::TestCase
Developer.with_scope(:find => { :conditions => 'salary = 100000' }) do
assert_equal 8, Developer.count
- assert_equal 1, Developer.count("name LIKE 'fixture_1%'")
+ assert_equal 1, Developer.count(:conditions => "name LIKE 'fixture_1%'")
end
end
@@ -74,7 +74,7 @@ class MethodScopingTest < Test::Unit::TestCase
def test_scoped_count_include
# with the include, will retrieve only developers for the given project
Developer.with_scope(:find => { :include => :projects }) do
- assert_equal 1, Developer.count('projects.id = 2')
+ assert_equal 1, Developer.count(:conditions => 'projects.id = 2')
end
end