acts_as_list 0.8.1 → 0.8.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +12 -1
- data/lib/acts_as_list/active_record/acts/list.rb +6 -4
- data/lib/acts_as_list/version.rb +1 -1
- data/test/shared_list_sub.rb +17 -0
- data/test/test_list.rb +30 -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: 5b311fb3c5f9b0839f22ff361020142db9c63045
|
4
|
+
data.tar.gz: 7600388596e829712e8936f9a31b70008ee7d18b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dc169373691b7a79c44393a368f4f589b04462c341f8f423f7eeedf846f29346dd3c6821f618287244a24ceafe04ebe416b4c6b6704f0be8470e69a1cd098a76
|
7
|
+
data.tar.gz: 748929065353ef8d675953d0469a4bd26ec8aee6921edfe6710b97186b25f75abc4a57bd648a2b076923cf5283e6dafb225ba0e6596efd21b23734897adc2f66
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,17 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## [v0.8.1](https://github.com/swanandp/acts_as_list/tree/v0.8.1) (2016-09-06)
|
4
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.8.0...v0.8.1)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- Rubinius Intermittent testing error [\#218](https://github.com/swanandp/acts_as_list/issues/218)
|
9
|
+
- ActiveRecord dependency causes rake assets:compile to fail without access to a database [\#84](https://github.com/swanandp/acts_as_list/issues/84)
|
10
|
+
|
11
|
+
**Merged pull requests:**
|
12
|
+
|
13
|
+
- Refactor class\_eval with string into class\_eval with block [\#215](https://github.com/swanandp/acts_as_list/pull/215) ([rdvdijk](https://github.com/rdvdijk))
|
14
|
+
|
3
15
|
## [v0.8.0](https://github.com/swanandp/acts_as_list/tree/v0.8.0) (2016-08-23)
|
4
16
|
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.7.7...v0.8.0)
|
5
17
|
|
@@ -75,7 +87,6 @@
|
|
75
87
|
- Creating an item with a nil scope should not add it to the list [\#92](https://github.com/swanandp/acts_as_list/issues/92)
|
76
88
|
- Performance Improvements [\#88](https://github.com/swanandp/acts_as_list/issues/88)
|
77
89
|
- has\_many :through or has\_many\_and\_belongs\_to\_many support [\#86](https://github.com/swanandp/acts_as_list/issues/86)
|
78
|
-
- ActiveRecord dependency causes rake assets:compile to fail without access to a database [\#84](https://github.com/swanandp/acts_as_list/issues/84)
|
79
90
|
- move\_higher/move\_lower vs move\_to\_top/move\_to\_bottom act differently when item is already at top or bottom [\#77](https://github.com/swanandp/acts_as_list/issues/77)
|
80
91
|
- Limiting the list size [\#61](https://github.com/swanandp/acts_as_list/issues/61)
|
81
92
|
- Adding multiple creates strange ordering [\#55](https://github.com/swanandp/acts_as_list/issues/55)
|
@@ -266,7 +266,8 @@ module ActiveRecord
|
|
266
266
|
limit ||= acts_as_list_list.count
|
267
267
|
position_value = send(position_column)
|
268
268
|
acts_as_list_list.
|
269
|
-
where("#{quoted_position_column_with_table_name}
|
269
|
+
where("#{quoted_position_column_with_table_name} <= ?", position_value).
|
270
|
+
where("#{quoted_table_name}.#{self.class.primary_key} != ?", self.send(self.class.primary_key)).
|
270
271
|
order("#{quoted_position_column_with_table_name} DESC").
|
271
272
|
limit(limit)
|
272
273
|
end
|
@@ -283,7 +284,8 @@ module ActiveRecord
|
|
283
284
|
limit ||= acts_as_list_list.count
|
284
285
|
position_value = send(position_column)
|
285
286
|
acts_as_list_list.
|
286
|
-
where("#{quoted_position_column_with_table_name}
|
287
|
+
where("#{quoted_position_column_with_table_name} >= ?", position_value).
|
288
|
+
where("#{quoted_table_name}.#{self.class.primary_key} != ?", self.send(self.class.primary_key)).
|
287
289
|
order("#{quoted_position_column_with_table_name} ASC").
|
288
290
|
limit(limit)
|
289
291
|
end
|
@@ -468,7 +470,7 @@ module ActiveRecord
|
|
468
470
|
end
|
469
471
|
|
470
472
|
def update_positions
|
471
|
-
old_position = send("#{position_column}_was")
|
473
|
+
old_position = send("#{position_column}_was") || bottom_position_in_list + 1
|
472
474
|
new_position = send(position_column).to_i
|
473
475
|
|
474
476
|
return unless acts_as_list_list.where(
|
@@ -523,4 +525,4 @@ module ActiveRecord
|
|
523
525
|
end
|
524
526
|
end
|
525
527
|
end
|
526
|
-
end
|
528
|
+
end
|
data/lib/acts_as_list/version.rb
CHANGED
data/test/shared_list_sub.rb
CHANGED
@@ -85,6 +85,23 @@ module Shared
|
|
85
85
|
assert_equal [], li1.higher_items
|
86
86
|
end
|
87
87
|
|
88
|
+
def test_next_prev_groups_with_same_position
|
89
|
+
li1 = ListMixin.where(id: 1).first
|
90
|
+
li2 = ListMixin.where(id: 2).first
|
91
|
+
li3 = ListMixin.where(id: 3).first
|
92
|
+
li4 = ListMixin.where(id: 4).first
|
93
|
+
|
94
|
+
li3.update_column(:pos, 2) # Make the same position as li2
|
95
|
+
|
96
|
+
assert_equal [1, 2, 2, 4], ListMixin.pluck(:pos)
|
97
|
+
|
98
|
+
assert_equal [li3, li4], li2.lower_items
|
99
|
+
assert_equal [li2, li4], li3.lower_items
|
100
|
+
|
101
|
+
assert_equal [li3, li1], li2.higher_items
|
102
|
+
assert_equal [li2, li1], li3.higher_items
|
103
|
+
end
|
104
|
+
|
88
105
|
def test_injection
|
89
106
|
item = ListMixin.new("parent_id"=>1)
|
90
107
|
assert_equal({ parent_id: 1 }, item.scope_condition)
|
data/test/test_list.rb
CHANGED
@@ -748,3 +748,33 @@ class ActsAsListTopTest < ActsAsListTestCase
|
|
748
748
|
assert_equal 0, ZeroBasedMixin.acts_as_list_top
|
749
749
|
end
|
750
750
|
end
|
751
|
+
|
752
|
+
class NilPositionTest < ActsAsListTestCase
|
753
|
+
def setup
|
754
|
+
setup_db
|
755
|
+
end
|
756
|
+
|
757
|
+
def test_nil_position_ordering
|
758
|
+
new1 = DefaultScopedMixin.create pos: nil
|
759
|
+
new2 = DefaultScopedMixin.create pos: nil
|
760
|
+
new3 = DefaultScopedMixin.create pos: nil
|
761
|
+
DefaultScopedMixin.update_all(pos: nil)
|
762
|
+
|
763
|
+
assert_equal [nil, nil, nil], DefaultScopedMixin.all.map(&:pos)
|
764
|
+
|
765
|
+
new1.reload.pos = 1
|
766
|
+
new1.save
|
767
|
+
|
768
|
+
new3.reload.pos = 1
|
769
|
+
new3.save
|
770
|
+
|
771
|
+
assert_equal [nil, 1, 2], DefaultScopedMixin.all.map(&:pos)
|
772
|
+
assert_equal [2, 3, 1], DefaultScopedMixin.all.map(&:id)
|
773
|
+
|
774
|
+
new2.reload.pos = 1
|
775
|
+
new2.save
|
776
|
+
|
777
|
+
assert_equal [1, 2, 3], DefaultScopedMixin.all.map(&:pos)
|
778
|
+
assert_equal [2, 3, 1], DefaultScopedMixin.all.map(&:id)
|
779
|
+
end
|
780
|
+
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.8.
|
4
|
+
version: 0.8.2
|
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: 2016-09-
|
13
|
+
date: 2016-09-23 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: activerecord
|