Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix #count_with_deleted so that it does not apply the deleted scope

git-svn-id: http://svn.techno-weenie.net/projects/plugins/acts_as_paranoid@1410 567b1171-46fb-0310-a4c9-b4bef9110e78
  • Loading branch information...
commit 17590f3a023b158862796977bbeae2d81f50f98b 1 parent 1b073c9
authored
5  lib/caboose/acts/paranoid.rb
@@ -53,7 +53,6 @@ def acts_as_paranoid(options = {})
53 53
             alias_method :destroy_without_callbacks!, :destroy_without_callbacks
54 54
             class << self
55 55
               alias_method :find_every_with_deleted,    :find_every
56  
-              alias_method :count_with_deleted,         :count
57 56
               alias_method :calculate_with_deleted,     :calculate
58 57
               alias_method :delete_all!,                :delete_all
59 58
             end
@@ -85,6 +84,10 @@ def find_with_deleted(*args)
85 84
             end
86 85
           end
87 86
 
  87
+          def count_with_deleted(*args)
  88
+            calculate_with_deleted(:count, *construct_count_options_from_legacy_args(*args))
  89
+          end
  90
+
88 91
           def count(*args)
89 92
             with_deleted_scope { count_with_deleted(*args) }
90 93
           end
6  test/paranoid_test.rb
@@ -27,6 +27,12 @@ class NonParanoidAndroid < ActiveRecord::Base
27 27
 class ParanoidTest < Test::Unit::TestCase
28 28
   fixtures :widgets, :categories, :categories_widgets
29 29
 
  30
+  def test_should_count_with_deleted
  31
+    assert_equal 1, Widget.count
  32
+    assert_equal 2, Widget.count_with_deleted
  33
+    assert_equal 2, Widget.calculate_with_deleted(:count, :all)
  34
+  end
  35
+
30 36
   def test_should_set_deleted_at
31 37
     assert_equal 1, Widget.count
32 38
     assert_equal 1, Category.count

0 notes on commit 17590f3

Please sign in to comment.
Something went wrong with that request. Please try again.