mongoid_orderable 6.0.3 → 6.0.4
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 +6 -1
- data/lib/mongoid/orderable/installer.rb +1 -0
- data/lib/mongoid/orderable/mixins/cascadeable.rb +15 -0
- data/lib/mongoid/orderable/version.rb +1 -1
- data/lib/mongoid_orderable.rb +1 -0
- data/spec/integration/cascadeable_spec.rb +12 -0
- data/spec/integration/embedded_spec.rb +27 -5
- data/spec/support/models.rb +1 -1
- metadata +9 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2babceab2f835fc658b2b41350208c65cc0aba49449b72a73e7275c84583479
|
4
|
+
data.tar.gz: ffdda4411505dc18f660dea2567a3d6d5e59aa40c6d95e9ef1a7404e4455c625
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 41e8f1cae5a56384b9f5b2a953218c1a11de6b66d5b3ef1459d7fa4404d97ccb1151127eaefba3027c83f0d701b74630ff31c4aa329d48b0067cab683122d9b4
|
7
|
+
data.tar.gz: f7f3195f9c63bb9daba132b83d7afa973e58c9afe743a69ea261621eb89454b669f497dc33b69e0d4eefc0e1245523b6da2c97797906dbf98469ab69d2c94e21
|
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,16 @@
|
|
1
|
-
### 6.0.
|
1
|
+
### 6.0.5 (Next)
|
2
2
|
|
3
3
|
* Your contribution here.
|
4
4
|
|
5
|
+
### 6.0.4 (Next)
|
6
|
+
|
7
|
+
* [#75](https://github.com/mongoid/mongoid_orderable/pull/75): Fix: Setting #move_to should mark an orderable object as changed so that callbacks are triggered.
|
8
|
+
|
5
9
|
### 6.0.3 (2021/06/27)
|
6
10
|
|
7
11
|
* [#72](https://github.com/mongoid/mongoid_orderable/pull/72): Feature: Add :if and :unless conditions which disable callbacks.
|
8
12
|
* [#71](https://github.com/mongoid/mongoid_orderable/pull/71): Fix: Add TTL index to locks table.
|
13
|
+
* [#73](https://github.com/mongoid/mongoid_orderable/pull/73): Refactor: Replace Travis CI with Github Actions.
|
9
14
|
|
10
15
|
### 6.0.2 (2021/01/26)
|
11
16
|
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
module Mongoid
|
4
|
+
module Orderable
|
5
|
+
module Mixins
|
6
|
+
# This is required to trigger callbacks on embedded objects.
|
7
|
+
# Otherwise, the #move_to parameter won't work when saving the parent.
|
8
|
+
module Cascadeable
|
9
|
+
def in_callback_state?(kind)
|
10
|
+
super || move_all.present?
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
data/lib/mongoid_orderable.rb
CHANGED
@@ -18,6 +18,7 @@ require 'mongoid/orderable/mixins/helpers'
|
|
18
18
|
require 'mongoid/orderable/mixins/callbacks'
|
19
19
|
require 'mongoid/orderable/mixins/listable'
|
20
20
|
require 'mongoid/orderable/mixins/movable'
|
21
|
+
require 'mongoid/orderable/mixins/cascadeable'
|
21
22
|
require 'mongoid/orderable/generators/base'
|
22
23
|
require 'mongoid/orderable/generators/listable'
|
23
24
|
require 'mongoid/orderable/generators/lock_collection'
|
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Mongoid::Orderable::Mixins::Cascadeable do
|
4
|
+
|
5
|
+
it do
|
6
|
+
eo = EmbedsOrderable.create!
|
7
|
+
orderable = eo.embedded_orderables.create!
|
8
|
+
expect(orderable.in_callback_state?(:update)).to eq false
|
9
|
+
orderable.move_to = 2
|
10
|
+
expect(orderable.in_callback_state?(:update)).to eq true
|
11
|
+
end
|
12
|
+
end
|
@@ -19,11 +19,33 @@ describe EmbeddedOrderable do
|
|
19
19
|
expect(positions).to eq([[1, 2], [1, 2, 3]])
|
20
20
|
end
|
21
21
|
|
22
|
-
it 'moves an item returned by a query to position' do
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
22
|
+
it 'move_to! moves an item returned by a query to position' do
|
23
|
+
parent = EmbedsOrderable.first
|
24
|
+
child1 = parent.embedded_orderables.where(position: 1).first
|
25
|
+
child2 = parent.embedded_orderables.where(position: 2).first
|
26
|
+
child1.move_to!(2)
|
27
|
+
expect(child1.reload.position).to eq(2)
|
28
|
+
expect(child2.reload.position).to eq(1)
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'move_to moves an item returned by a query to position when saving the parent' do
|
32
|
+
parent = EmbedsOrderable.first
|
33
|
+
child1 = parent.embedded_orderables.where(position: 1).first
|
34
|
+
child2 = parent.embedded_orderables.where(position: 2).first
|
35
|
+
child1.move_to(2)
|
36
|
+
parent.save!
|
37
|
+
expect(child1.reload.position).to eq(2)
|
38
|
+
expect(child2.reload.position).to eq(1)
|
39
|
+
end
|
40
|
+
|
41
|
+
it 'move_to= moves an item returned by a query to position when saving the parent' do
|
42
|
+
parent = EmbedsOrderable.first
|
43
|
+
child1 = parent.embedded_orderables.where(position: 1).first
|
44
|
+
child2 = parent.embedded_orderables.where(position: 2).first
|
45
|
+
child1.move_to = 2
|
46
|
+
parent.save!
|
47
|
+
expect(child1.reload.position).to eq(2)
|
48
|
+
expect(child2.reload.position).to eq(1)
|
27
49
|
end
|
28
50
|
end
|
29
51
|
|
data/spec/support/models.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoid_orderable
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.0.
|
4
|
+
version: 6.0.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- pyromaniac
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2023-01-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -111,11 +111,13 @@ files:
|
|
111
111
|
- lib/mongoid/orderable/handlers/transaction.rb
|
112
112
|
- lib/mongoid/orderable/installer.rb
|
113
113
|
- lib/mongoid/orderable/mixins/callbacks.rb
|
114
|
+
- lib/mongoid/orderable/mixins/cascadeable.rb
|
114
115
|
- lib/mongoid/orderable/mixins/helpers.rb
|
115
116
|
- lib/mongoid/orderable/mixins/listable.rb
|
116
117
|
- lib/mongoid/orderable/mixins/movable.rb
|
117
118
|
- lib/mongoid/orderable/version.rb
|
118
119
|
- lib/mongoid_orderable.rb
|
120
|
+
- spec/integration/cascadeable_spec.rb
|
119
121
|
- spec/integration/concurrency_spec.rb
|
120
122
|
- spec/integration/conditional_spec.rb
|
121
123
|
- spec/integration/customized_spec.rb
|
@@ -135,7 +137,7 @@ homepage: https://github.com/mongoid/mongoid_orderable
|
|
135
137
|
licenses:
|
136
138
|
- MIT
|
137
139
|
metadata: {}
|
138
|
-
post_install_message:
|
140
|
+
post_install_message:
|
139
141
|
rdoc_options: []
|
140
142
|
require_paths:
|
141
143
|
- lib
|
@@ -150,11 +152,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
150
152
|
- !ruby/object:Gem::Version
|
151
153
|
version: '0'
|
152
154
|
requirements: []
|
153
|
-
rubygems_version: 3.
|
154
|
-
signing_key:
|
155
|
+
rubygems_version: 3.4.4
|
156
|
+
signing_key:
|
155
157
|
specification_version: 4
|
156
158
|
summary: Mongoid orderable list implementation
|
157
159
|
test_files:
|
160
|
+
- spec/integration/cascadeable_spec.rb
|
158
161
|
- spec/integration/concurrency_spec.rb
|
159
162
|
- spec/integration/conditional_spec.rb
|
160
163
|
- spec/integration/customized_spec.rb
|