acts_as_list 0.9.18 → 0.9.19
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 +4 -0
- data/lib/acts_as_list/active_record/acts/no_update.rb +14 -4
- data/lib/acts_as_list/version.rb +1 -1
- data/test/test_no_update_for_extra_classes.rb +25 -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: 01e6f5e3817634aa371273af2786776b0e0dd9e5
|
|
4
|
+
data.tar.gz: c305a4fa8ea72eebbac9aa74a1933d6713741d1a
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 99c8762a0530f4f3e2cce408eb156f9a6eaa85a3b9d9194ad1f0858f4d47095365726a29a188b8b69a9d7a7d70c4bb828db1386c3c46d23134e341c56fac8731
|
|
7
|
+
data.tar.gz: 9faea6f72ce9cc2ea854eaa921390d5edc212a1a94018e149fae835fd480dc8175bbcc5a8645fecd29763bea00d7950d06222972b1d9e1bef2087cd540c4e471
|
data/CHANGELOG.md
CHANGED
|
@@ -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
|
-
|
|
92
|
+
klasses.map {|klass| add_klass(klass)}
|
|
93
93
|
yield
|
|
94
94
|
ensure
|
|
95
|
-
|
|
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
|
|
data/lib/acts_as_list/version.rb
CHANGED
|
@@ -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.
|
|
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-
|
|
13
|
+
date: 2019-03-11 00:00:00.000000000 Z
|
|
14
14
|
dependencies:
|
|
15
15
|
- !ruby/object:Gem::Dependency
|
|
16
16
|
name: activerecord
|