From e0a7e0fec760ba12c8067a37e10c96f1f05876e2 Mon Sep 17 00:00:00 2001 From: erdgeist Date: Wed, 24 Jun 2026 04:13:16 +0200 Subject: Stage 1 complete: Rails 2.3.5 to Rails 3.2.22.5 upgrade - Converted plugins to gems (Gemfile) - Updated config structure (application.rb, boot.rb, environment.rb) - Converted routes to Rails 3 DSL - Converted named_scope to scope throughout models - Converted find(:all, :conditions) to where() chains - Fixed has_many :order to use ordering scope - Updated session store and secret token configuration - Fixed exception_notification middleware configuration - Patched Ruby 2.4 / Rails 3.2 incompatibilities: - Integer/Float duration arithmetic (ActiveSupport) - Arel visit_Integer for PostgreSQL adapter - create_database String/Integer coercion - ActionController consider_all_requests_local - Migrated taggings schema for acts-as-taggable-on - Replaced dynamic_form gem with custom form_error_messages helper - Fixed Rails 3 block helper syntax (form_for, form_tag, fields_for) - Fixed admin layout yield - Updated test suite for Rails 3 APIs --- vendor/plugins/acts_as_list/test/list_test.rb | 332 -------------------------- 1 file changed, 332 deletions(-) delete mode 100644 vendor/plugins/acts_as_list/test/list_test.rb (limited to 'vendor/plugins/acts_as_list/test') diff --git a/vendor/plugins/acts_as_list/test/list_test.rb b/vendor/plugins/acts_as_list/test/list_test.rb deleted file mode 100644 index e89cb8e1..00000000 --- a/vendor/plugins/acts_as_list/test/list_test.rb +++ /dev/null @@ -1,332 +0,0 @@ -require 'test/unit' - -require 'rubygems' -gem 'activerecord', '>= 1.15.4.7794' -require 'active_record' - -require "#{File.dirname(__FILE__)}/../init" - -ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :dbfile => ":memory:") - -def setup_db - ActiveRecord::Schema.define(:version => 1) do - create_table :mixins do |t| - t.column :pos, :integer - t.column :parent_id, :integer - t.column :created_at, :datetime - t.column :updated_at, :datetime - end - end -end - -def teardown_db - ActiveRecord::Base.connection.tables.each do |table| - ActiveRecord::Base.connection.drop_table(table) - end -end - -class Mixin < ActiveRecord::Base -end - -class ListMixin < Mixin - acts_as_list :column => "pos", :scope => :parent - - def self.table_name() "mixins" end -end - -class ListMixinSub1 < ListMixin -end - -class ListMixinSub2 < ListMixin -end - -class ListWithStringScopeMixin < ActiveRecord::Base - acts_as_list :column => "pos", :scope => 'parent_id = #{parent_id}' - - def self.table_name() "mixins" end -end - - -class ListTest < Test::Unit::TestCase - - def setup - setup_db - (1..4).each { |counter| ListMixin.create! :pos => counter, :parent_id => 5 } - end - - def teardown - teardown_db - end - - def test_reordering - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).move_lower - assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).move_higher - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(1).move_to_bottom - assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(1).move_to_top - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).move_to_bottom - assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(4).move_to_top - assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - end - - def test_move_to_bottom_with_next_to_last_item - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - ListMixin.find(3).move_to_bottom - assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - end - - def test_next_prev - assert_equal ListMixin.find(2), ListMixin.find(1).lower_item - assert_nil ListMixin.find(1).higher_item - assert_equal ListMixin.find(3), ListMixin.find(4).higher_item - assert_nil ListMixin.find(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 [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).destroy - - assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(1).pos - assert_equal 2, ListMixin.find(3).pos - assert_equal 3, ListMixin.find(4).pos - - ListMixin.find(1).destroy - - assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(3).pos - assert_equal 2, ListMixin.find(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 - - - def test_remove_from_list_should_then_fail_in_list? - assert_equal true, ListMixin.find(1).in_list? - ListMixin.find(1).remove_from_list - assert_equal false, ListMixin.find(1).in_list? - end - - def test_remove_from_list_should_set_position_to_nil - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).remove_from_list - - assert_equal [2, 1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(1).pos - assert_equal nil, ListMixin.find(2).pos - assert_equal 2, ListMixin.find(3).pos - assert_equal 3, ListMixin.find(4).pos - end - - def test_remove_before_destroy_does_not_shift_lower_items_twice - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - ListMixin.find(2).remove_from_list - ListMixin.find(2).destroy - - assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(1).pos - assert_equal 2, ListMixin.find(3).pos - assert_equal 3, ListMixin.find(4).pos - end - -end - -class ListSubTest < Test::Unit::TestCase - - def setup - setup_db - (1..4).each { |i| ((i % 2 == 1) ? ListMixinSub1 : ListMixinSub2).create! :pos => i, :parent_id => 5000 } - end - - def teardown - teardown_db - end - - def test_reordering - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(2).move_lower - assert_equal [1, 3, 2, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(2).move_higher - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(1).move_to_bottom - assert_equal [2, 3, 4, 1], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(1).move_to_top - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(2).move_to_bottom - assert_equal [1, 3, 4, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(4).move_to_top - assert_equal [4, 1, 3, 2], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - end - - def test_move_to_bottom_with_next_to_last_item - assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - ListMixin.find(3).move_to_bottom - assert_equal [1, 2, 4, 3], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - end - - def test_next_prev - assert_equal ListMixin.find(2), ListMixin.find(1).lower_item - assert_nil ListMixin.find(1).higher_item - assert_equal ListMixin.find(3), ListMixin.find(4).higher_item - assert_nil ListMixin.find(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 [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - ListMixin.find(2).destroy - - assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(1).pos - assert_equal 2, ListMixin.find(3).pos - assert_equal 3, ListMixin.find(4).pos - - ListMixin.find(1).destroy - - assert_equal [3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5000', :order => 'pos').map(&:id) - - assert_equal 1, ListMixin.find(3).pos - assert_equal 2, ListMixin.find(4).pos - end - -end -- cgit v1.3