Skip to content

Commit

Permalink
Update for Edge rails: remove support for legacy #count args
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.techno-weenie.net/projects/plugins/acts_as_paranoid@2987 567b1171-46fb-0310-a4c9-b4bef9110e78
  • Loading branch information
technoweenie committed Oct 4, 2007
1 parent 7db4f9e commit e2fc7bd
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
6 changes: 5 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* (4 Oct 2007)

Update for Edge rails: remove support for legacy #count args

* (2 Feb 2007)

Add support for custom primary keys [Jeff Dean]
Expand Down Expand Up @@ -67,4 +71,4 @@ Updated for Rails 1.1. I love removing code.

*0.1* (17 Sep 2005)

* Initial gem
* Initial gem
2 changes: 1 addition & 1 deletion lib/caboose/acts/paranoid.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def find_with_deleted(*args)
end

def count_with_deleted(*args)
calculate_with_deleted(:count, *construct_count_options_from_legacy_args(*args))
calculate_with_deleted(:count, *construct_count_options_from_args(*args))
end

def count(*args)
Expand Down
18 changes: 9 additions & 9 deletions test/paranoid_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ def test_should_delete_all_with_conditions2

def test_should_not_count_deleted
assert_equal 1, Widget.count
assert_equal 1, Widget.count(['title=?', 'widget 1'])
assert_equal 1, Widget.count(:all, :conditions => ['title=?', 'widget 1'])
assert_equal 2, Widget.calculate_with_deleted(:count, :all)
end

Expand Down Expand Up @@ -142,19 +142,19 @@ def test_should_ignore_multiple_includes
end

def test_should_not_override_scopes_when_counting
assert_equal 1, Widget.with_scope(:find => { :conditions => "title = 'widget 1'" }) { Widget.count }
assert_equal 0, Widget.with_scope(:find => { :conditions => "title = 'deleted widget 2'" }) { Widget.count }
assert_equal 1, Widget.with_scope(:find => { :conditions => "title = 'deleted widget 2'" }) { Widget.calculate_with_deleted(:count, :all) }
assert_equal 1, Widget.send(:with_scope, :find => { :conditions => "title = 'widget 1'" }) { Widget.count }
assert_equal 0, Widget.send(:with_scope, :find => { :conditions => "title = 'deleted widget 2'" }) { Widget.count }
assert_equal 1, Widget.send(:with_scope, :find => { :conditions => "title = 'deleted widget 2'" }) { Widget.calculate_with_deleted(:count, :all) }
end

def test_should_not_override_scopes_when_finding
assert_equal [1], Widget.with_scope(:find => { :conditions => "title = 'widget 1'" }) { Widget.find(:all) }.ids
assert_equal [], Widget.with_scope(:find => { :conditions => "title = 'deleted widget 2'" }) { Widget.find(:all) }.ids
assert_equal [2], Widget.with_scope(:find => { :conditions => "title = 'deleted widget 2'" }) { Widget.find_with_deleted(:all) }.ids
assert_equal [1], Widget.send(:with_scope, :find => { :conditions => "title = 'widget 1'" }) { Widget.find(:all) }.ids
assert_equal [], Widget.send(:with_scope, :find => { :conditions => "title = 'deleted widget 2'" }) { Widget.find(:all) }.ids
assert_equal [2], Widget.send(:with_scope, :find => { :conditions => "title = 'deleted widget 2'" }) { Widget.find_with_deleted(:all) }.ids
end

def test_should_allow_multiple_scoped_calls_when_finding
Widget.with_scope(:find => { :conditions => "title = 'deleted widget 2'" }) do
Widget.send(:with_scope, :find => { :conditions => "title = 'deleted widget 2'" }) do
assert_equal [2], Widget.find_with_deleted(:all).ids
assert_equal [2], Widget.find_with_deleted(:all).ids, "clobbers the constrain on the unmodified find"
assert_equal [], Widget.find(:all).ids
Expand All @@ -163,7 +163,7 @@ def test_should_allow_multiple_scoped_calls_when_finding
end

def test_should_allow_multiple_scoped_calls_when_counting
Widget.with_scope(:find => { :conditions => "title = 'deleted widget 2'" }) do
Widget.send(:with_scope, :find => { :conditions => "title = 'deleted widget 2'" }) do
assert_equal 1, Widget.calculate_with_deleted(:count, :all)
assert_equal 1, Widget.calculate_with_deleted(:count, :all), "clobbers the constrain on the unmodified find"
assert_equal 0, Widget.count
Expand Down

0 comments on commit e2fc7bd

Please sign in to comment.