acts_as_list 0.9.4 → 0.9.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +7 -0
- data/lib/acts_as_list/active_record/acts/list.rb +15 -9
- data/lib/acts_as_list/version.rb +1 -1
- data/test/helper.rb +1 -0
- data/test/test_list.rb +7 -1
- 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: 66daa5cd56691f7a638ae9dd8f1a9c3feec0577c
|
|
4
|
+
data.tar.gz: 7574120085bc23b698489eeb890112df78dd7689
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: acad50db58bda1347963b54c71929bf9d79fce33e47b3efc0c3d7f2ffe17a370ff984c3ff83796e3a31350ec10fce07d2448d95adf796cf1661166070f06ada6
|
|
7
|
+
data.tar.gz: 7d3bdb848e5a1bc50ed1b5e620eaaaa940cb956a23f1fc12649ca1fab410a2dd3d9df8e0190fd6229ec69048c0066fad59d86d5f48ef07b8e2602d3b1bcf4ee8
|
data/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
+
## [v0.9.4](https://github.com/swanandp/acts_as_list/tree/v0.9.4) (2017-03-16)
|
|
4
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.9.3...v0.9.4)
|
|
5
|
+
|
|
6
|
+
**Merged pull requests:**
|
|
7
|
+
|
|
8
|
+
- Optimize first? and last? instance methods. [\#262](https://github.com/swanandp/acts_as_list/pull/262) ([marshall-lee](https://github.com/marshall-lee))
|
|
9
|
+
|
|
3
10
|
## [v0.9.3](https://github.com/swanandp/acts_as_list/tree/v0.9.3) (2017-03-14)
|
|
4
11
|
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.9.2...v0.9.3)
|
|
5
12
|
|
|
@@ -164,7 +164,7 @@ module ActiveRecord
|
|
|
164
164
|
acts_as_list_list.
|
|
165
165
|
where("#{quoted_position_column_with_table_name} <= ?", position_value).
|
|
166
166
|
where("#{quoted_table_name}.#{self.class.primary_key} != ?", self.send(self.class.primary_key)).
|
|
167
|
-
|
|
167
|
+
reorder("#{quoted_position_column_with_table_name} DESC").
|
|
168
168
|
limit(limit)
|
|
169
169
|
end
|
|
170
170
|
|
|
@@ -182,7 +182,7 @@ module ActiveRecord
|
|
|
182
182
|
acts_as_list_list.
|
|
183
183
|
where("#{quoted_position_column_with_table_name} >= ?", position_value).
|
|
184
184
|
where("#{quoted_table_name}.#{self.class.primary_key} != ?", self.send(self.class.primary_key)).
|
|
185
|
-
|
|
185
|
+
reorder("#{quoted_position_column_with_table_name} ASC").
|
|
186
186
|
limit(limit)
|
|
187
187
|
end
|
|
188
188
|
|
|
@@ -219,8 +219,12 @@ module ActiveRecord
|
|
|
219
219
|
end
|
|
220
220
|
|
|
221
221
|
def acts_as_list_list
|
|
222
|
-
|
|
223
|
-
acts_as_list_class.
|
|
222
|
+
if ActiveRecord::VERSION::MAJOR < 4
|
|
223
|
+
acts_as_list_class.unscoped do
|
|
224
|
+
acts_as_list_class.where(scope_condition)
|
|
225
|
+
end
|
|
226
|
+
else
|
|
227
|
+
acts_as_list_class.unscope(:where).where(scope_condition)
|
|
224
228
|
end
|
|
225
229
|
end
|
|
226
230
|
|
|
@@ -274,7 +278,7 @@ module ActiveRecord
|
|
|
274
278
|
scope = scope.where("#{quoted_table_name}.#{self.class.primary_key} != ?", except.id)
|
|
275
279
|
end
|
|
276
280
|
|
|
277
|
-
scope.in_list.
|
|
281
|
+
scope.in_list.reorder("#{quoted_position_column_with_table_name} DESC").first
|
|
278
282
|
end
|
|
279
283
|
|
|
280
284
|
# Forces item to assume the bottom position in the list.
|
|
@@ -346,7 +350,7 @@ module ActiveRecord
|
|
|
346
350
|
)
|
|
347
351
|
|
|
348
352
|
if sequential_updates?
|
|
349
|
-
items.
|
|
353
|
+
items.reorder("#{quoted_position_column_with_table_name} ASC").each do |item|
|
|
350
354
|
item.decrement!(position_column)
|
|
351
355
|
end
|
|
352
356
|
else
|
|
@@ -364,7 +368,7 @@ module ActiveRecord
|
|
|
364
368
|
)
|
|
365
369
|
|
|
366
370
|
if sequential_updates?
|
|
367
|
-
items.
|
|
371
|
+
items.reorder("#{quoted_position_column_with_table_name} DESC").each do |item|
|
|
368
372
|
item.increment!(position_column)
|
|
369
373
|
end
|
|
370
374
|
else
|
|
@@ -382,7 +386,7 @@ module ActiveRecord
|
|
|
382
386
|
# temporary move after bottom with gap, avoiding duplicate values
|
|
383
387
|
# gap is required to leave room for position increments
|
|
384
388
|
# positive number will be valid with unique not null check (>= 0) db constraint
|
|
385
|
-
temporary_position =
|
|
389
|
+
temporary_position = bottom_position_in_list + 2
|
|
386
390
|
set_list_position(temporary_position)
|
|
387
391
|
shuffle_positions_on_intermediate_items(old_position, position, id)
|
|
388
392
|
else
|
|
@@ -403,7 +407,9 @@ module ActiveRecord
|
|
|
403
407
|
end
|
|
404
408
|
|
|
405
409
|
def position_before_save
|
|
406
|
-
if ActiveRecord::VERSION::MAJOR
|
|
410
|
+
if ActiveRecord::VERSION::MAJOR == 5 && ActiveRecord::VERSION::MINOR >= 1 ||
|
|
411
|
+
ActiveRecord::VERSION::MAJOR > 5
|
|
412
|
+
|
|
407
413
|
send("#{position_column}_before_last_save")
|
|
408
414
|
else
|
|
409
415
|
send("#{position_column}_was")
|
data/lib/acts_as_list/version.rb
CHANGED
data/test/helper.rb
CHANGED
data/test/test_list.rb
CHANGED
|
@@ -103,7 +103,13 @@ class DefaultScopedWhereMixin < Mixin
|
|
|
103
103
|
default_scope { order('pos ASC').where(active: true) }
|
|
104
104
|
|
|
105
105
|
def self.for_active_false_tests
|
|
106
|
-
|
|
106
|
+
if ActiveRecord::VERSION::MAJOR < 4
|
|
107
|
+
unscoped do
|
|
108
|
+
order('pos ASC').where(active: false)
|
|
109
|
+
end
|
|
110
|
+
else
|
|
111
|
+
unscope(:where).where(active: false)
|
|
112
|
+
end
|
|
107
113
|
end
|
|
108
114
|
end
|
|
109
115
|
|
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.5
|
|
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: 2017-
|
|
13
|
+
date: 2017-04-04 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activerecord
|