acts_as_list 0.9.16 → 0.9.17
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +14 -0
- data/lib/acts_as_list/active_record/acts/list.rb +3 -8
- data/lib/acts_as_list/version.rb +1 -1
- data/test/test_list.rb +22 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fab8be3ea9754103e60311aaa592f0ab4b7c84e3
|
4
|
+
data.tar.gz: 166a2aff0b3f6cbb6cfc67709de71fda2f4b3960
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5afeff2ad86a92fb1261062596b2646508dee23473242686bf20ccf809623834705e467c3ad701963eba9a46c839f29fc2f3aba4adbce62dbe49d91e810f628d
|
7
|
+
data.tar.gz: 037aa8e4d42c306040f7e2da8c9f9615e1c1a1c123df08edb7d1cb511fadb63a388f65567a45e20ea58a3444905f024f38da10fa54b0e55cdd3c610587539af4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,19 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.9.16](https://github.com/swanandp/acts_as_list/tree/v0.9.16) (2018-08-30)
|
4
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.9.15...v0.9.16)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- Re-ordering at specific position [\#318](https://github.com/swanandp/acts_as_list/issues/318)
|
9
|
+
- `no\_update` is not applied to subclasses [\#314](https://github.com/swanandp/acts_as_list/issues/314)
|
10
|
+
- NoMethodError: undefined method `acts\_as\_list' [\#303](https://github.com/swanandp/acts_as_list/issues/303)
|
11
|
+
- Cannot create item at position 0 [\#297](https://github.com/swanandp/acts_as_list/issues/297)
|
12
|
+
|
13
|
+
**Merged pull requests:**
|
14
|
+
|
15
|
+
- Unscope `select` to avoid PG::UndefinedFunction [\#283](https://github.com/swanandp/acts_as_list/pull/283) ([donv](https://github.com/donv))
|
16
|
+
|
3
17
|
## [v0.9.15](https://github.com/swanandp/acts_as_list/tree/v0.9.15) (2018-06-11)
|
4
18
|
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.9.14...v0.9.15)
|
5
19
|
|
@@ -105,20 +105,14 @@ module ActiveRecord
|
|
105
105
|
# position adjusted accordingly.
|
106
106
|
def move_to_bottom
|
107
107
|
return unless in_list?
|
108
|
-
|
109
|
-
decrement_positions_on_lower_items
|
110
|
-
assume_bottom_position
|
111
|
-
end
|
108
|
+
insert_at_position bottom_position_in_list.to_i
|
112
109
|
end
|
113
110
|
|
114
111
|
# Move to the top of the list. If the item is already in the list, the items above it have their
|
115
112
|
# position adjusted accordingly.
|
116
113
|
def move_to_top
|
117
114
|
return unless in_list?
|
118
|
-
|
119
|
-
increment_positions_on_higher_items
|
120
|
-
assume_top_position
|
121
|
-
end
|
115
|
+
insert_at_position acts_as_list_top
|
122
116
|
end
|
123
117
|
|
124
118
|
# Removes the item from the list.
|
@@ -399,6 +393,7 @@ module ActiveRecord
|
|
399
393
|
end
|
400
394
|
|
401
395
|
def insert_at_position(position, raise_exception_if_save_fails=false)
|
396
|
+
raise ArgumentError.new("position cannot be lower than top") if position < acts_as_list_top
|
402
397
|
return set_list_position(position, raise_exception_if_save_fails) if new_record?
|
403
398
|
with_lock do
|
404
399
|
if in_list?
|
data/lib/acts_as_list/version.rb
CHANGED
data/test/test_list.rb
CHANGED
@@ -897,6 +897,20 @@ class SequentialUpdatesMixinNotNullUniquePositiveConstraintsTest < ActsAsListTes
|
|
897
897
|
assert_equal 3, new.pos
|
898
898
|
end
|
899
899
|
|
900
|
+
def test_move_to_bottom
|
901
|
+
item = SequentialUpdatesDefault.order(:pos).first
|
902
|
+
item.move_to_bottom
|
903
|
+
assert_equal 4, item.pos
|
904
|
+
end
|
905
|
+
|
906
|
+
def test_move_to_top
|
907
|
+
new_item = SequentialUpdatesDefault.create!
|
908
|
+
assert_equal 5, new_item.pos
|
909
|
+
|
910
|
+
new_item.move_to_top
|
911
|
+
assert_equal 1, new_item.pos
|
912
|
+
end
|
913
|
+
|
900
914
|
def test_destroy
|
901
915
|
new_item = SequentialUpdatesDefault.create
|
902
916
|
assert_equal 5, new_item.pos
|
@@ -908,4 +922,12 @@ class SequentialUpdatesMixinNotNullUniquePositiveConstraintsTest < ActsAsListTes
|
|
908
922
|
assert_equal [1,2,3,4], SequentialUpdatesDefault.all.map(&:pos).sort
|
909
923
|
|
910
924
|
end
|
925
|
+
|
926
|
+
def test_exception_on_wrong_position
|
927
|
+
new_item = SequentialUpdatesDefault.create
|
928
|
+
|
929
|
+
assert_raises ArgumentError do
|
930
|
+
new_item.insert_at(0)
|
931
|
+
end
|
932
|
+
end
|
911
933
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.17
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Heinemeier Hansson
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2018-
|
13
|
+
date: 2018-10-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|