Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #7323: acts_as_list_tests_patch.diff

File acts_as_list_tests_patch.diff, 2.3 kB (added by lonestarsoftware, 2 years ago)
  • activerecord/test/mixin_test.rb

    old new  
    8282 
    8383  end 
    8484 
     85  def test_delete_all 
     86    assert_equal 4, ListMixinParent.find(5).list_mixins.count 
     87    ListMixinParent.find(5).list_mixins.delete_all 
     88    assert_equal 0, ListMixinParent.find(5).list_mixins.count 
     89  end 
     90 
    8591  def test_move_to_bottom_with_next_to_last_item 
    8692    assert_equal [mixins(:list_1), 
    8793                  mixins(:list_2), 
  • activerecord/test/fixtures/mixin.rb

    old new  
    1515  has_one :first_child, :class_name => 'RecursivelyCascadedTreeMixin', :foreign_key => :parent_id 
    1616end 
    1717 
     18class ListMixinParent < Mixin 
     19  has_many :list_mixins, :foreign_key =>  :parent_id 
     20  def self.table_name() "mixins" end 
     21end 
     22 
    1823class ListMixin < Mixin 
     24  belongs_to :list_mixin_parent, :foreign_key => :parent_id 
    1925  acts_as_list :column => "pos", :scope => :parent 
    20  
    2126  def self.table_name() "mixins" end 
    2227end 
    2328 
  • activerecord/test/fixtures/mixins.yml

    old new  
    6060  parent_id: 5007 
    6161 
    6262# List mixins 
     63parent: 
     64  id: 5 
     65  type: ListMixinParent 
     66  parent_id:  
    6367 
    64 <% (1..4).each do |counter| %>   
     68<% [4,2,3,1].each do |counter| %>   
    6569list_<%= counter %>: 
    6670  id: <%= counter+1006 %> 
    6771  pos: <%= counter  %> 
     
    6973  parent_id: 5 
    7074<% end %> 
    7175 
     76 
    7277# Nested set mixins 
    7378 
    7479<% (1..10).each do |counter| %>   
  • activerecord/test/fixtures/db_definitions/mysql.sql

    old new  
    130130  PRIMARY KEY  (`id`) 
    131131) TYPE=InnoDB; 
    132132 
     133ALTER TABLE mixins ADD UNIQUE INDEX (parent_id, pos); 
     134 
    133135CREATE TABLE `people` ( 
    134136  `id` INTEGER NOT NULL auto_increment PRIMARY KEY, 
    135137  `first_name` VARCHAR(40) NOT NULL,