ryanb (owner)

Revisions

gist: 242 Download_button fork
public
Public Clone URL: git://gist.github.com/242.git
Embed All Files: show embed
acts_as_list_test.rb #
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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