acts_as_list 0.9.4 → 0.9.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b89748f05d5967e1a76360d733d46cce9e8d792c
4
- data.tar.gz: f5cedd8786d6d4a4ab5fb2446974b05fe481bf95
3
+ metadata.gz: 66daa5cd56691f7a638ae9dd8f1a9c3feec0577c
4
+ data.tar.gz: 7574120085bc23b698489eeb890112df78dd7689
5
5
  SHA512:
6
- metadata.gz: b6e8877539d4c8d88a53fe4b81b78835541f5ea9906a8a0da51e6dc9f615e72a519116f8fecf37053654bbf5cd605bc9d70d5a86c8317f0cb86a4346bf28a826
7
- data.tar.gz: 23dc051623bd30cce636ec1db440a1d7cbaae9bf66c16397f4a602fa94f3899c6f5a1a1d82becaee0c2ce176c16ef6818d6ad0d935764a0171aa77b01f744619
6
+ metadata.gz: acad50db58bda1347963b54c71929bf9d79fce33e47b3efc0c3d7f2ffe17a370ff984c3ff83796e3a31350ec10fce07d2448d95adf796cf1661166070f06ada6
7
+ data.tar.gz: 7d3bdb848e5a1bc50ed1b5e620eaaaa940cb956a23f1fc12649ca1fab410a2dd3d9df8e0190fd6229ec69048c0066fad59d86d5f48ef07b8e2602d3b1bcf4ee8
@@ -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
- order("#{quoted_position_column_with_table_name} DESC").
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
- order("#{quoted_position_column_with_table_name} ASC").
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
- acts_as_list_class.unscoped do
223
- acts_as_list_class.where(scope_condition)
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.order("#{quoted_position_column_with_table_name} DESC").first
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.order("#{quoted_position_column_with_table_name} ASC").each do |item|
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.order("#{quoted_position_column_with_table_name} DESC").each do |item|
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 = acts_as_list_class.maximum(position_column).to_i + 2
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 >= 5 && ActiveRecord::VERSION::MINOR >= 1
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")
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module Acts
3
3
  module List
4
- VERSION = '0.9.4'
4
+ VERSION = '0.9.5'
5
5
  end
6
6
  end
7
7
  end
@@ -48,6 +48,7 @@ end
48
48
 
49
49
  require "shared"
50
50
 
51
+ # require 'logger'
51
52
  # ActiveRecord::Base.logger = Logger.new(STDOUT)
52
53
 
53
54
  def assert_equal_or_nil(a, b)
@@ -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
- unscoped.order('pos ASC').where(active: false)
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
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-03-16 00:00:00.000000000 Z
13
+ date: 2017-04-04 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord