acts_as_list 0.1.3 → 0.1.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -21,11 +21,11 @@ Gem::Specification.new do |s|
21
21
  s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
22
22
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
23
23
  s.require_paths = ['lib']
24
-
25
-
24
+
25
+
26
26
  # Dependencies (installed via 'bundle install')...
27
27
  s.add_development_dependency("bundler", ["~> 1.0.0"])
28
28
  s.add_development_dependency("activerecord", [">= 1.15.4.7794"])
29
29
  s.add_development_dependency("rdoc")
30
- s.add_development_dependency("sqlite3-ruby")
30
+ s.add_development_dependency("sqlite3")
31
31
  end
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module Acts
3
3
  module List
4
- VERSION = "0.1.3"
4
+ VERSION = "0.1.4"
5
5
  end
6
6
  end
7
7
  end
@@ -10,6 +10,3 @@ end
10
10
  require 'test/unit'
11
11
  require 'active_record'
12
12
  require "#{File.dirname(__FILE__)}/../init"
13
-
14
-
15
-
@@ -1,12 +1,6 @@
1
1
  # NOTE: following now done in helper.rb (better Readability)
2
- #require 'test/unit'
3
- #require 'rubygems'
4
- #gem 'activerecord', '>= 1.15.4.7794'
5
- #require 'active_record'
6
- #require "#{File.dirname(__FILE__)}/../init"
7
2
  require 'helper.rb'
8
3
 
9
-
10
4
  ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
11
5
 
12
6
  def setup_db
@@ -15,7 +9,7 @@ def setup_db
15
9
  t.column :pos, :integer
16
10
  t.column :parent_id, :integer
17
11
  t.column :parent_type, :string
18
- t.column :created_at, :datetime
12
+ t.column :created_at, :datetime
19
13
  t.column :updated_at, :datetime
20
14
  end
21
15
  end
@@ -98,7 +92,6 @@ class ZeroBasedTest < Test::Unit::TestCase
98
92
  assert new.last?
99
93
  end
100
94
 
101
-
102
95
  def test_reordering
103
96
  assert_equal [1, 2, 3, 4], ZeroBasedMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
104
97
 
@@ -300,49 +293,49 @@ class ListTest < Test::Unit::TestCase
300
293
  assert_equal [new2, new1, new3], ListMixin.find(:all, :conditions => 'parent_id IS NULL', :order => 'pos')
301
294
  end
302
295
 
303
- def test_remove_from_list_should_then_fail_in_list?
296
+ def test_remove_from_list_should_then_fail_in_list?
304
297
  assert_equal true, ListMixin.find(1).in_list?
305
298
  ListMixin.find(1).remove_from_list
306
299
  assert_equal false, ListMixin.find(1).in_list?
307
- end
308
-
309
- def test_remove_from_list_should_set_position_to_nil
300
+ end
301
+
302
+ def test_remove_from_list_should_set_position_to_nil
310
303
  assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
311
-
312
- ListMixin.find(2).remove_from_list
313
-
304
+
305
+ ListMixin.find(2).remove_from_list
306
+
314
307
  assert_equal [2, 1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
315
-
308
+
316
309
  assert_equal 1, ListMixin.find(1).pos
317
310
  assert_equal nil, ListMixin.find(2).pos
318
311
  assert_equal 2, ListMixin.find(3).pos
319
312
  assert_equal 3, ListMixin.find(4).pos
320
- end
321
-
322
- def test_remove_before_destroy_does_not_shift_lower_items_twice
313
+ end
314
+
315
+ def test_remove_before_destroy_does_not_shift_lower_items_twice
323
316
  assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
324
-
325
- ListMixin.find(2).remove_from_list
326
- ListMixin.find(2).destroy
327
-
317
+
318
+ ListMixin.find(2).remove_from_list
319
+ ListMixin.find(2).destroy
320
+
328
321
  assert_equal [1, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
329
-
322
+
330
323
  assert_equal 1, ListMixin.find(1).pos
331
324
  assert_equal 2, ListMixin.find(3).pos
332
325
  assert_equal 3, ListMixin.find(4).pos
333
- end
334
-
326
+ end
327
+
335
328
  def test_before_destroy_callbacks_do_not_update_position_to_nil_before_deleting_the_record
336
329
  assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
337
330
 
338
331
  # We need to trigger all the before_destroy callbacks without actually
339
332
  # destroying the record so we can see the affect the callbacks have on
340
- # the record.
333
+ # the record.
341
334
  # NOTE: Hotfix for rails3 ActiveRecord
342
335
  list = ListMixin.find(2)
343
336
  if list.respond_to?(:run_callbacks)
344
337
  # Refactored to work according to Rails3 ActiveRSupport Callbacks <http://api.rubyonrails.org/classes/ActiveSupport/Callbacks.html>
345
- list.run_callbacks :destroy, :before if rails_3
338
+ list.run_callbacks :destroy, :before if rails_3
346
339
  list.run_callbacks(:before_destroy) if !rails_3
347
340
  else
348
341
  list.send(:callback, :before_destroy)
@@ -355,7 +348,7 @@ class ListTest < Test::Unit::TestCase
355
348
  assert_equal 2, ListMixin.find(3).pos
356
349
  assert_equal 3, ListMixin.find(4).pos
357
350
  end
358
-
351
+
359
352
  def test_before_create_callback_adds_to_bottom
360
353
  assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
361
354
 
@@ -363,9 +356,9 @@ class ListTest < Test::Unit::TestCase
363
356
  assert_equal 5, new.pos
364
357
  assert !new.first?
365
358
  assert new.last?
366
-
359
+
367
360
  assert_equal [1, 2, 3, 4, 5], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
368
- end
361
+ end
369
362
 
370
363
  def test_before_create_callback_adds_to_given_position
371
364
  assert_equal [1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
@@ -374,7 +367,7 @@ class ListTest < Test::Unit::TestCase
374
367
  assert_equal 1, new.pos
375
368
  assert new.first?
376
369
  assert !new.last?
377
-
370
+
378
371
  assert_equal [5, 1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
379
372
 
380
373
  new = ListMixin.create(:pos => 3, :parent_id => 5)
@@ -383,8 +376,7 @@ class ListTest < Test::Unit::TestCase
383
376
  assert !new.last?
384
377
 
385
378
  assert_equal [5, 1, 6, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
386
- end
387
-
379
+ end
388
380
  end
389
381
 
390
382
  class ListSubTest < Test::Unit::TestCase
@@ -622,38 +614,37 @@ class ArrayScopeListTest < Test::Unit::TestCase
622
614
  assert_equal 1, ArrayScopeListMixin.find(3).pos
623
615
  assert_equal 2, ArrayScopeListMixin.find(4).pos
624
616
  end
625
-
626
- def test_remove_from_list_should_then_fail_in_list?
617
+
618
+ def test_remove_from_list_should_then_fail_in_list?
627
619
  assert_equal true, ArrayScopeListMixin.find(1).in_list?
628
620
  ArrayScopeListMixin.find(1).remove_from_list
629
621
  assert_equal false, ArrayScopeListMixin.find(1).in_list?
630
- end
631
-
632
- def test_remove_from_list_should_set_position_to_nil
622
+ end
623
+
624
+ def test_remove_from_list_should_set_position_to_nil
633
625
  assert_equal [1, 2, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id)
634
-
635
- ArrayScopeListMixin.find(2).remove_from_list
636
-
626
+
627
+ ArrayScopeListMixin.find(2).remove_from_list
628
+
637
629
  assert_equal [2, 1, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id)
638
-
630
+
639
631
  assert_equal 1, ArrayScopeListMixin.find(1).pos
640
632
  assert_equal nil, ArrayScopeListMixin.find(2).pos
641
633
  assert_equal 2, ArrayScopeListMixin.find(3).pos
642
634
  assert_equal 3, ArrayScopeListMixin.find(4).pos
643
- end
644
-
645
- def test_remove_before_destroy_does_not_shift_lower_items_twice
635
+ end
636
+
637
+ def test_remove_before_destroy_does_not_shift_lower_items_twice
646
638
  assert_equal [1, 2, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id)
647
-
648
- ArrayScopeListMixin.find(2).remove_from_list
649
- ArrayScopeListMixin.find(2).destroy
650
-
639
+
640
+ ArrayScopeListMixin.find(2).remove_from_list
641
+ ArrayScopeListMixin.find(2).destroy
642
+
651
643
  assert_equal [1, 3, 4], ArrayScopeListMixin.find(:all, :conditions => "parent_id = 5 AND parent_type = 'ParentClass'", :order => 'pos').map(&:id)
652
-
644
+
653
645
  assert_equal 1, ArrayScopeListMixin.find(1).pos
654
646
  assert_equal 2, ArrayScopeListMixin.find(3).pos
655
647
  assert_equal 3, ArrayScopeListMixin.find(4).pos
656
- end
657
-
658
- end
648
+ end
659
649
 
650
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_list
3
3
  version: !ruby/object:Gem::Version
4
- hash: 29
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 1
9
- - 3
10
- version: 0.1.3
9
+ - 4
10
+ version: 0.1.4
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Heinemeier Hansson
@@ -17,7 +17,7 @@ autorequire:
17
17
  bindir: bin
18
18
  cert_chain: []
19
19
 
20
- date: 2011-06-10 00:00:00 +05:30
20
+ date: 2011-07-27 00:00:00 +05:30
21
21
  default_executable:
22
22
  dependencies:
23
23
  - !ruby/object:Gem::Dependency
@@ -68,7 +68,7 @@ dependencies:
68
68
  type: :development
69
69
  version_requirements: *id003
70
70
  - !ruby/object:Gem::Dependency
71
- name: sqlite3-ruby
71
+ name: sqlite3
72
72
  prerelease: false
73
73
  requirement: &id004 !ruby/object:Gem::Requirement
74
74
  none: false