acts_as_list 0.9.18 → 0.9.19

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: c7f90b8a37019ae091449a79440aca7cb8862960
4
- data.tar.gz: db75dccae8c652a84e9dfaaffb2f195ca238b442
3
+ metadata.gz: 01e6f5e3817634aa371273af2786776b0e0dd9e5
4
+ data.tar.gz: c305a4fa8ea72eebbac9aa74a1933d6713741d1a
5
5
  SHA512:
6
- metadata.gz: 65c7f4c2b1ee583aeb3f2ddc8a9c9c07b5428ad6b0d4b3f5d45e0ad9f1e2a55b7ac98c1f0f1ea7a4ee79969bf2bd343b748f1b9463c65a6635120a3235ad02c1
7
- data.tar.gz: 8bd08749b808b25f33e9f8f398731973625ff0ee42dc76080944a94ab88ca6e817412609af0897d69db7e2c7a8843a36a5a90177fffee17d2cadbfa483a87df8
6
+ metadata.gz: 99c8762a0530f4f3e2cce408eb156f9a6eaa85a3b9d9194ad1f0858f4d47095365726a29a188b8b69a9d7a7d70c4bb828db1386c3c46d23134e341c56fac8731
7
+ data.tar.gz: 9faea6f72ce9cc2ea854eaa921390d5edc212a1a94018e149fae835fd480dc8175bbcc5a8645fecd29763bea00d7950d06222972b1d9e1bef2087cd540c4e471
@@ -6,6 +6,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.9.19] - 2019-03-12
10
+ ### Added
11
+ - Allow `acts_as_list_no_update` blocks to be nested [@conorbdaly](https://github.com/conorbdaly)
12
+
9
13
  ## [0.9.18] - 2019-03-08
10
14
  ### Added
11
15
  - Added additional gemspec metadata [@boone](https://github.com/boone)
@@ -89,20 +89,30 @@ module ActiveRecord
89
89
 
90
90
  class << self
91
91
  def apply_to(klasses)
92
- extracted_klasses.push(*klasses)
92
+ klasses.map {|klass| add_klass(klass)}
93
93
  yield
94
94
  ensure
95
- extracted_klasses.clear
95
+ klasses.map {|klass| remove_klass(klass)}
96
96
  end
97
97
 
98
98
  def applied_to?(klass)
99
- !(klass.ancestors & extracted_klasses).empty?
99
+ !(klass.ancestors & extracted_klasses.keys).empty?
100
100
  end
101
101
 
102
102
  private
103
103
 
104
104
  def extracted_klasses
105
- Thread.current[:act_as_list_no_update] ||= []
105
+ Thread.current[:act_as_list_no_update] ||= {}
106
+ end
107
+
108
+ def add_klass(klass)
109
+ extracted_klasses[klass] = 0 unless extracted_klasses.key?(klass)
110
+ extracted_klasses[klass] += 1
111
+ end
112
+
113
+ def remove_klass(klass)
114
+ extracted_klasses[klass] -= 1
115
+ extracted_klasses.delete(klass) if extracted_klasses[klass] <= 0
106
116
  end
107
117
  end
108
118
 
@@ -3,7 +3,7 @@
3
3
  module ActiveRecord
4
4
  module Acts
5
5
  module List
6
- VERSION = '0.9.18'
6
+ VERSION = '0.9.19'
7
7
  end
8
8
  end
9
9
  end
@@ -52,6 +52,7 @@ class NoUpdateForCollectionClassesTest < NoUpdateForCollectionClassesTestCase
52
52
 
53
53
  @item_1, @item_2 = (1..2).map { |counter| TodoItem.create!(position: counter, todo_list_id: @list_1.id) }
54
54
  @attachment_1, @attachment_2 = (1..2).map { |counter| TodoItemAttachment.create!(position: counter, todo_item_id: @item_1.id) }
55
+ @attachment_3, @attachment_4 = (1..2).map {|counter| TodoItemAttachment.create!(position: counter, todo_item_id: @item_2.id)}
55
56
  end
56
57
 
57
58
  def test_update
@@ -80,6 +81,30 @@ class NoUpdateForCollectionClassesTest < NoUpdateForCollectionClassesTestCase
80
81
  assert_equal 1, @list_2.reload.position
81
82
  end
82
83
 
84
+ def test_no_update_for_nested_blocks
85
+ new_list = @list_1.dup
86
+ new_list.save!
87
+
88
+ TodoItem.acts_as_list_no_update do
89
+ @list_1.todo_items.reverse.each do |item|
90
+ new_item = item.dup
91
+ new_list.todo_items << new_item
92
+ new_item.save!
93
+
94
+ assert_equal new_item.position, item.reload.position
95
+
96
+ TodoItemAttachment.acts_as_list_no_update do
97
+ item.todo_item_attachments.reverse.each do |attach|
98
+ new_attach = attach.dup
99
+ new_item.todo_item_attachments << new_attach
100
+ new_attach.save!
101
+ assert_equal new_attach.position, attach.reload.position
102
+ end
103
+ end
104
+ end
105
+ end
106
+ end
107
+
83
108
  def test_raising_array_type_error
84
109
  exception = assert_raises ActiveRecord::Acts::List::NoUpdate::ArrayTypeError do
85
110
  TodoList.acts_as_list_no_update(nil)
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.18
4
+ version: 0.9.19
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: 2019-03-07 00:00:00.000000000 Z
13
+ date: 2019-03-11 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord