aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/mixin_test.rb
diff options
context:
space:
mode:
authorMichael Koziarski <michael@koziarski.com>2007-09-10 04:41:09 +0000
committerMichael Koziarski <michael@koziarski.com>2007-09-10 04:41:09 +0000
commitaa36ca1c5fe81120d0b2ad428fadec3c586fafa2 (patch)
tree3faca9bbc6d61312fcdaa38e14c883ffead11e18 /activerecord/test/mixin_test.rb
parent2807ccc69a54805e3914bcc21716f9bafbebef39 (diff)
downloadrails-aa36ca1c5fe81120d0b2ad428fadec3c586fafa2.tar.gz
rails-aa36ca1c5fe81120d0b2ad428fadec3c586fafa2.tar.bz2
rails-aa36ca1c5fe81120d0b2ad428fadec3c586fafa2.zip
Remove acts_as_list. Users are advised to install the new plugin. References #9415. [josh, nzkoz]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@7444 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/test/mixin_test.rb')
-rw-r--r--activerecord/test/mixin_test.rb282
1 files changed, 0 insertions, 282 deletions
diff --git a/activerecord/test/mixin_test.rb b/activerecord/test/mixin_test.rb
index 44a84f62c8..41310e2c83 100644
--- a/activerecord/test/mixin_test.rb
+++ b/activerecord/test/mixin_test.rb
@@ -1,6 +1,5 @@
require 'abstract_unit'
require 'active_record/acts/tree'
-require 'active_record/acts/list'
require 'active_record/acts/nested_set'
require 'fixtures/mixin'
@@ -21,164 +20,6 @@ class Time
end
end
-class ListTest < Test::Unit::TestCase
- fixtures :mixins
-
- def test_reordering
- assert_equal mixins(:list_1, :list_2, :list_3, :list_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- mixins(:list_2).move_lower
-
- assert_equal mixins(:list_1, :list_3, :list_2, :list_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- mixins(:list_2).move_higher
-
- assert_equal mixins(:list_1, :list_2, :list_3, :list_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- mixins(:list_1).move_to_bottom
-
- assert_equal mixins(:list_2, :list_3, :list_4, :list_1),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- mixins(:list_1).move_to_top
-
- assert_equal mixins(:list_1, :list_2, :list_3, :list_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
-
- mixins(:list_2).move_to_bottom
-
- assert_equal mixins(:list_1, :list_3, :list_4, :list_2),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- mixins(:list_4).move_to_top
-
- assert_equal mixins(:list_4, :list_1, :list_3, :list_2),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- end
-
- def test_move_to_bottom_with_next_to_last_item
- assert_equal mixins(:list_1, :list_2, :list_3, :list_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- mixins(:list_3).move_to_bottom
-
- assert_equal mixins(:list_1, :list_2, :list_4, :list_3),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
- end
-
- def test_next_prev
- assert_equal mixins(:list_2), mixins(:list_1).lower_item
- assert_nil mixins(:list_1).higher_item
- assert_equal mixins(:list_3), mixins(:list_4).higher_item
- assert_nil mixins(:list_4).lower_item
- end
-
-
- def test_injection
- item = ListMixin.new("parent_id"=>1)
- assert_equal "parent_id = 1", item.scope_condition
- assert_equal "pos", item.position_column
- end
-
- def test_insert
- new = ListMixin.create("parent_id"=>20)
- assert_equal 1, new.pos
- assert new.first?
- assert new.last?
-
- new = ListMixin.create("parent_id"=>20)
- assert_equal 2, new.pos
- assert !new.first?
- assert new.last?
-
- new = ListMixin.create("parent_id"=>20)
- assert_equal 3, new.pos
- assert !new.first?
- assert new.last?
-
- new = ListMixin.create("parent_id"=>0)
- assert_equal 1, new.pos
- assert new.first?
- assert new.last?
- end
-
- def test_insert_at
- new = ListMixin.create("parent_id" => 20)
- assert_equal 1, new.pos
-
- new = ListMixin.create("parent_id" => 20)
- assert_equal 2, new.pos
-
- new = ListMixin.create("parent_id" => 20)
- assert_equal 3, new.pos
-
- new4 = ListMixin.create("parent_id" => 20)
- assert_equal 4, new4.pos
-
- new4.insert_at(3)
- assert_equal 3, new4.pos
-
- new.reload
- assert_equal 4, new.pos
-
- new.insert_at(2)
- assert_equal 2, new.pos
-
- new4.reload
- assert_equal 4, new4.pos
-
- new5 = ListMixin.create("parent_id" => 20)
- assert_equal 5, new5.pos
-
- new5.insert_at(1)
- assert_equal 1, new5.pos
-
- new4.reload
- assert_equal 5, new4.pos
- end
-
- def test_delete_middle
- assert_equal mixins(:list_1, :list_2, :list_3, :list_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- mixins(:list_2).destroy
-
- assert_equal mixins(:list_1, :list_3, :list_4, :reload),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- assert_equal 1, mixins(:list_1).pos
- assert_equal 2, mixins(:list_3).pos
- assert_equal 3, mixins(:list_4).pos
-
- mixins(:list_1).destroy
-
- assert_equal mixins(:list_3, :list_4, :reload),
- ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos')
-
- assert_equal 1, mixins(:list_3).pos
- assert_equal 2, mixins(:list_4).pos
-
- end
-
- def test_with_string_based_scope
- new = ListWithStringScopeMixin.create("parent_id"=>500)
- assert_equal 1, new.pos
- assert new.first?
- assert new.last?
- end
-
- def test_nil_scope
- new1, new2, new3 = ListMixin.create, ListMixin.create, ListMixin.create
- new2.move_higher
- assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos')
- end
-
-end
class TreeTest < Test::Unit::TestCase
fixtures :mixins
@@ -339,128 +180,5 @@ class TouchTest < Test::Unit::TestCase
end
-class ListSubTest < Test::Unit::TestCase
- fixtures :mixins
-
- def test_reordering
- assert_equal mixins(:list_sub_1, :list_sub_2, :list_sub_3, :list_sub_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- mixins(:list_sub_2).move_lower
-
- assert_equal mixins(:list_sub_1, :list_sub_3, :list_sub_2, :list_sub_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- mixins(:list_sub_2).move_higher
-
- assert_equal mixins(:list_sub_1, :list_sub_2, :list_sub_3, :list_sub_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- mixins(:list_sub_1).move_to_bottom
-
- assert_equal mixins(:list_sub_2, :list_sub_3, :list_sub_4, :list_sub_1),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- mixins(:list_sub_1).move_to_top
-
- assert_equal mixins(:list_sub_1, :list_sub_2, :list_sub_3, :list_sub_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
-
- mixins(:list_sub_2).move_to_bottom
-
- assert_equal mixins(:list_sub_1, :list_sub_3, :list_sub_4, :list_sub_2),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- mixins(:list_sub_4).move_to_top
-
- assert_equal mixins(:list_sub_4, :list_sub_1, :list_sub_3, :list_sub_2),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- end
-
- def test_move_to_bottom_with_next_to_last_item
- assert_equal mixins(:list_sub_1, :list_sub_2, :list_sub_3, :list_sub_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- mixins(:list_sub_3).move_to_bottom
-
- assert_equal mixins(:list_sub_1, :list_sub_2, :list_sub_4, :list_sub_3),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
- end
-
- def test_next_prev
- assert_equal mixins(:list_sub_2), mixins(:list_sub_1).lower_item
- assert_nil mixins(:list_sub_1).higher_item
- assert_equal mixins(:list_sub_3), mixins(:list_sub_4).higher_item
- assert_nil mixins(:list_sub_4).lower_item
- end
-
-
- def test_injection
- item = ListMixin.new("parent_id"=>1)
- assert_equal "parent_id = 1", item.scope_condition
- assert_equal "pos", item.position_column
- end
-
-
- def test_insert_at
- new = ListMixin.create("parent_id" => 20)
- assert_equal 1, new.pos
-
- new = ListMixinSub1.create("parent_id" => 20)
- assert_equal 2, new.pos
-
- new = ListMixinSub2.create("parent_id" => 20)
- assert_equal 3, new.pos
-
- new4 = ListMixin.create("parent_id" => 20)
- assert_equal 4, new4.pos
-
- new4.insert_at(3)
- assert_equal 3, new4.pos
-
- new.reload
- assert_equal 4, new.pos
-
- new.insert_at(2)
- assert_equal 2, new.pos
-
- new4.reload
- assert_equal 4, new4.pos
-
- new5 = ListMixinSub1.create("parent_id" => 20)
- assert_equal 5, new5.pos
- new5.insert_at(1)
- assert_equal 1, new5.pos
-
- new4.reload
- assert_equal 5, new4.pos
- end
-
- def test_delete_middle
- assert_equal mixins(:list_sub_1, :list_sub_2, :list_sub_3, :list_sub_4),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- mixins(:list_sub_2).destroy
-
- assert_equal mixins(:list_sub_1, :list_sub_3, :list_sub_4, :reload),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- assert_equal 1, mixins(:list_sub_1).pos
- assert_equal 2, mixins(:list_sub_3).pos
- assert_equal 3, mixins(:list_sub_4).pos
-
- mixins(:list_sub_1).destroy
-
- assert_equal mixins(:list_sub_3, :list_sub_4, :reload),
- ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos')
-
- assert_equal 1, mixins(:list_sub_3).pos
- assert_equal 2, mixins(:list_sub_4).pos
-
- end
-
-end