acts_as_list 0.9.9 → 0.9.10

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b6d2515099c8746c438ada6bfd3307841f7a66d7
4
- data.tar.gz: 3d5980d4d52abd7957daef5f851caceb967fd7e1
3
+ metadata.gz: 6a5fd4ed86fc8761d3281f89b396aa5062d2efae
4
+ data.tar.gz: 5caf258018d36923b25c1cf4b21829b506de2feb
5
5
  SHA512:
6
- metadata.gz: b9bc5985bcccdd1f02cd4f5f814d5abba57745c29c28ea158a95de849f4e36954a9a944919fbefe418af4518a32d58746a0427474a4055bbe44672d8e4b54e94
7
- data.tar.gz: 048b80713d0cf58cbd717d337d58869ae0b5c09704c1a40a9503e6d05a4979be8ee517d9dc2c1877445d2c0194854f5c01a5ad220d8210414ca1ba80afed2fc6
6
+ metadata.gz: 206f7896be7a435f3330af74f2737256c1fd30a2a54ecd7900e369bec037e8a0317a14771d1cfe80405852a42bb6cd7570b518c9d43d98e18fc983b692a3f475
7
+ data.tar.gz: de4fd257055e8aa86e6bbf1c0aa5d9358b91592465cba7a44661219a916f94a68555b02dd33718a3a2e69e3b79f1533020317ad00043ce77f4bf071c72f57f65
@@ -1,5 +1,20 @@
1
1
  # Change Log
2
2
 
3
+ ## [Unreleased](https://github.com/swanandp/acts_as_list/tree/HEAD)
4
+
5
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.9.9...HEAD)
6
+
7
+ **Closed issues:**
8
+
9
+ - Why does acts\_as\_list override rails validation on it's own field? [\#269](https://github.com/swanandp/acts_as_list/issues/269)
10
+
11
+ ## [v0.9.9](https://github.com/swanandp/acts_as_list/tree/v0.9.9) (2017-10-03)
12
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.9.8...v0.9.9)
13
+
14
+ **Merged pull requests:**
15
+
16
+ - Added fixed values option for scope array [\#286](https://github.com/swanandp/acts_as_list/pull/286) ([hooverlunch](https://github.com/hooverlunch))
17
+
3
18
  ## [v0.9.8](https://github.com/swanandp/acts_as_list/tree/v0.9.8) (2017-09-28)
4
19
  [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.9.7...v0.9.8)
5
20
 
@@ -234,7 +234,7 @@ module ActiveRecord
234
234
  # has been set manually using position=, not necessarily the top or bottom of the list:
235
235
 
236
236
  def add_to_list_top
237
- if not_in_list? || internal_scope_changed? && !position_changed || default_position?
237
+ if assume_default_position?
238
238
  increment_positions_on_all_items
239
239
  self[position_column] = acts_as_list_top
240
240
  else
@@ -249,7 +249,7 @@ module ActiveRecord
249
249
  end
250
250
 
251
251
  def add_to_list_bottom
252
- if not_in_list? || internal_scope_changed? && !position_changed || default_position?
252
+ if assume_default_position?
253
253
  self[position_column] = bottom_position_in_list.to_i + 1
254
254
  else
255
255
  increment_positions_on_lower_items(self[position_column], id)
@@ -262,6 +262,12 @@ module ActiveRecord
262
262
  true
263
263
  end
264
264
 
265
+ def assume_default_position?
266
+ not_in_list? ||
267
+ persisted? && internal_scope_changed? && !position_changed ||
268
+ default_position?
269
+ end
270
+
265
271
  # Overwrite this method to define the scope of the list changes
266
272
  def scope_condition() {} end
267
273
 
@@ -7,13 +7,13 @@ module ActiveRecord
7
7
  base.extend ClassMethods
8
8
  end
9
9
 
10
- class ArrayTypeError < SyntaxError
10
+ class ArrayTypeError < ArgumentError
11
11
  def initialize
12
12
  super("The first argument must be an array")
13
13
  end
14
14
  end
15
15
 
16
- class DisparityClassesError < NotImplementedError
16
+ class DisparityClassesError < ArgumentError
17
17
  def initialize
18
18
  super("The first argument should contain ActiveRecord or ApplicationRecord classes")
19
19
  end
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module Acts
3
3
  module List
4
- VERSION = '0.9.9'
4
+ VERSION = '0.9.10'
5
5
  end
6
6
  end
7
7
  end
@@ -124,6 +124,18 @@ module Shared
124
124
  assert_equal [$default_position, 1, 2, 3, 4, 5], pos_list
125
125
  end
126
126
 
127
+ def test_insert_at_after_dup
128
+ new1 = ListMixin.create(parent_id: 20)
129
+ new2 = ListMixin.create(parent_id: 20)
130
+ new3 = ListMixin.create(parent_id: 20)
131
+
132
+ duped = new1.dup
133
+ duped.save
134
+ [new1, new2, new3, duped].map(&:reload)
135
+
136
+ assert_equal [1, 2, 3, 4], [duped.pos, new1.pos, new2.pos, new3.pos]
137
+ end
138
+
127
139
  def test_delete_middle
128
140
  assert_equal [1, 2, 3, 4], ListMixin.where(parent_id: 5).order('pos').map(&:id)
129
141
 
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.9
4
+ version: 0.9.10
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-10-03 00:00:00.000000000 Z
13
+ date: 2017-11-19 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord