acts_as_silent_list 1.1.0 → 1.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ = 1.2.0 - 2011-10-26
2
+
3
+ == Features
4
+
5
+ * adding insert_at_top and insert_at_bottom
6
+
1
7
  = 1.1.0 - 2011-10-19
2
8
 
3
9
  == Features
@@ -97,6 +97,20 @@ module ActiveRecord
97
97
  # <tt>chapter.first?</tt> would return +true+ if that chapter is the first
98
98
  # in the list of all chapters.
99
99
  module InstanceMethods
100
+ # Insert the item at the top of the list
101
+ #
102
+ # N.B.: This method is not part of the acts_as_list API
103
+ def insert_at_top
104
+ insert_at
105
+ end
106
+
107
+ # Insert the item at the bottom of the list
108
+ #
109
+ # N.B.: This method is not part of the acts_as_list API
110
+ def insert_at_bottom
111
+ assume_bottom_position
112
+ end
113
+
100
114
  # Insert the item at the given position
101
115
  # (defaults to the top position of 1).
102
116
  def insert_at(position = acts_as_silent_list_top)
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module Acts
3
3
  module SilentList
4
- VERSION = "1.1.0"
4
+ VERSION = "1.2.0"
5
5
  end
6
6
  end
7
7
  end
data/test/test_list.rb CHANGED
@@ -416,6 +416,24 @@ class ListTest < Test::Unit::TestCase
416
416
 
417
417
  assert_equal [5, 1, 6, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
418
418
  end
419
+
420
+ def test_insert_at_top
421
+ new = ListMixin.create(:parent_id => 5)
422
+
423
+ new.insert_at_top
424
+
425
+ assert new.first?
426
+ assert_equal [5, 1, 2, 3, 4], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
427
+ end
428
+
429
+ def test_insert_at_bottom
430
+ new = ListMixin.create(:parent_id => 5)
431
+
432
+ new.insert_at_bottom
433
+
434
+ assert new.last?
435
+ assert_equal [1, 2, 3, 4, 5], ListMixin.find(:all, :conditions => 'parent_id = 5', :order => 'pos').map(&:id)
436
+ end
419
437
  end
420
438
 
421
439
  class ListSubTest < Test::Unit::TestCase
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_silent_list
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 31
5
5
  prerelease:
6
6
  segments:
7
7
  - 1
8
- - 1
8
+ - 2
9
9
  - 0
10
- version: 1.1.0
10
+ version: 1.2.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - David Heinemeier Hansson
@@ -18,7 +18,7 @@ autorequire:
18
18
  bindir: bin
19
19
  cert_chain: []
20
20
 
21
- date: 2011-10-19 00:00:00 +02:00
21
+ date: 2011-10-26 00:00:00 +02:00
22
22
  default_executable:
23
23
  dependencies:
24
24
  - !ruby/object:Gem::Dependency