activeinteractor 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (52) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +10 -3
  3. data/lib/active_interactor/interactor/worker.rb +7 -1
  4. data/lib/active_interactor/organizer/perform.rb +8 -9
  5. data/lib/active_interactor/version.rb +1 -1
  6. metadata +7 -127
  7. data/spec/active_interactor/base_spec.rb +0 -85
  8. data/spec/active_interactor/config_spec.rb +0 -17
  9. data/spec/active_interactor/context/base_spec.rb +0 -443
  10. data/spec/active_interactor/error_spec.rb +0 -45
  11. data/spec/active_interactor/interactor/perform/options_spec.rb +0 -25
  12. data/spec/active_interactor/interactor/worker_spec.rb +0 -189
  13. data/spec/active_interactor/organizer/base_spec.rb +0 -276
  14. data/spec/active_interactor/organizer/interactor_interface_collection_spec.rb +0 -78
  15. data/spec/active_interactor/organizer/interactor_interface_spec.rb +0 -235
  16. data/spec/active_interactor/version_spec.rb +0 -119
  17. data/spec/active_interactor_spec.rb +0 -23
  18. data/spec/integration/a_basic_interactor_spec.rb +0 -154
  19. data/spec/integration/a_basic_organizer_spec.rb +0 -354
  20. data/spec/integration/a_failing_interactor_spec.rb +0 -43
  21. data/spec/integration/active_record_integration_spec.rb +0 -32
  22. data/spec/integration/an_interactor_with_after_context_validation_callbacks_spec.rb +0 -69
  23. data/spec/integration/an_interactor_with_after_perform_callbacks_spec.rb +0 -31
  24. data/spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb +0 -34
  25. data/spec/integration/an_interactor_with_an_existing_context_class_spec.rb +0 -50
  26. data/spec/integration/an_interactor_with_around_perform_callbacks_spec.rb +0 -35
  27. data/spec/integration/an_interactor_with_around_rollback_callbacks_spec.rb +0 -39
  28. data/spec/integration/an_interactor_with_before_perform_callbacks_spec.rb +0 -31
  29. data/spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb +0 -34
  30. data/spec/integration/an_interactor_with_deferred_after_callbacks.rb +0 -32
  31. data/spec/integration/an_interactor_with_validations_on_called_spec.rb +0 -41
  32. data/spec/integration/an_interactor_with_validations_on_calling_spec.rb +0 -37
  33. data/spec/integration/an_interactor_with_validations_spec.rb +0 -95
  34. data/spec/integration/an_organizer_containing_organizer_with_after_callbacks_deferred_spec.rb +0 -125
  35. data/spec/integration/an_organizer_performing_in_parallel_spec.rb +0 -48
  36. data/spec/integration/an_organizer_with_after_callbacks_deferred_spec.rb +0 -154
  37. data/spec/integration/an_organizer_with_after_each_callbacks_spec.rb +0 -35
  38. data/spec/integration/an_organizer_with_all_perform_callbacks.rb +0 -112
  39. data/spec/integration/an_organizer_with_around_each_callbacks_spec.rb +0 -39
  40. data/spec/integration/an_organizer_with_before_each_callbacks_spec.rb +0 -35
  41. data/spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb +0 -326
  42. data/spec/integration/an_organizer_with_failing_nested_organizer_spec.rb +0 -47
  43. data/spec/integration/an_organizer_with_options_callbacks_spec.rb +0 -64
  44. data/spec/spec_helper.rb +0 -33
  45. data/spec/support/coverage.rb +0 -50
  46. data/spec/support/helpers/factories.rb +0 -49
  47. data/spec/support/shared_examples/a_class_that_extends_active_interactor_models_example.rb +0 -81
  48. data/spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb +0 -107
  49. data/spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb +0 -60
  50. data/spec/support/shared_examples/a_class_with_interactor_methods_example.rb +0 -21
  51. data/spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb +0 -42
  52. data/spec/support/spec_helpers.rb +0 -7
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 47d39868b8ed69a4ae27d9cf931e42ed6e5a5daa893a7adc0c6b696bd0b4035d
4
- data.tar.gz: 9e4ae3e6102d6f6ead6d8fb4af150dc8d67124adfba1afd26420a54e57708cc7
3
+ metadata.gz: 764c2b65284b79d85ff2a20f7c5d9a3c3983dd06a869c7cc961b530ef77a7d28
4
+ data.tar.gz: 02cdcb760098151105d1b9d1367ee2cefca765353b0ebcd302141dcea009c198
5
5
  SHA512:
6
- metadata.gz: 06e1686b7e98a6ed13f136e5f847c836a4f018ba4a89c1b42e6666a4063600c22c2b6b7ad48a378462a9b0fc18f3dd28d88325bd7344c9a9647c2274804d1e01
7
- data.tar.gz: 925e3b0ab0a9562efe52d4d30d55b71b327d9169f02eed1ab1b22b9c72caa00ca5c72b1a587782f0d7c9e820465739538240666263dc9a2c999037e00e060710
6
+ metadata.gz: 8a87326136160d7d3fe3cbea58b42b42b80206249938d7adf9496f000c260c490c902f32d1dc78983e67e05d1559a190a4738cb73dfa166c7f5deafb9a637547
7
+ data.tar.gz: cc3789900b6a46067a51944f1d8280455e41b014ceb31b5d9e1819fe2e7836f84e9bc5c79871a4fd72f7ad4d85146cf18b9554dd7f15955c8c0f4d7b017aa20a
data/CHANGELOG.md CHANGED
@@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning].
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [v1.2.2] - 2023-09-30
11
+
12
+ ### Fixed
13
+
14
+ - [\#366] Fixes a minor timing issue for when deferred after_perform callbacks are run.
15
+
10
16
  ## [v1.2.1] - 2022-09-26
11
17
 
12
18
  ### Fixed
@@ -21,7 +27,7 @@ and this project adheres to [Semantic Versioning].
21
27
 
22
28
  ## [v1.2.0] - 2022-09-08
23
29
 
24
- ### Added
30
+
25
31
 
26
32
  - `ActiveInteractor::Base.defer_after_callbacks_when_organized`
27
33
  - `ActiveInteractor::Organizer::Base.after_all_perform`
@@ -270,9 +276,10 @@ and this project adheres to [Semantic Versioning].
270
276
 
271
277
  <!-- versions -->
272
278
 
273
- [Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.2.1...HEAD
279
+ [Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.2.2...HEAD
280
+ [v1.2.2]: https://github.com/aaronmallen/activeinteractor/compare/v1.2.1...v1.2.2
274
281
  [v1.2.1]: https://github.com/aaronmallen/activeinteractor/compare/v1.2.0...v1.2.1
275
- [v1.2.0]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.6...v1.2.0
282
+ [v1.2.0]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.7...v1.2.0
276
283
  [v1.1.7]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.6...v1.1.7
277
284
  [v1.1.6]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.4...v1.1.6
278
285
  [v1.1.4]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.3...v1.1.4
@@ -60,10 +60,16 @@ module ActiveInteractor
60
60
  end
61
61
 
62
62
  def execute_context_with_callbacks!
63
- interactor.run_callbacks :perform do
63
+ result = interactor.run_callbacks :perform do
64
64
  execute_context_with_validation_check!
65
65
  @context = interactor.finalize_context!
66
66
  end
67
+
68
+ if context&.success? && interactor.respond_to?(:run_deferred_after_perform_callbacks_on_children)
69
+ interactor.run_deferred_after_perform_callbacks_on_children
70
+ end
71
+
72
+ result
67
73
  end
68
74
 
69
75
  def execute_context_with_validation!
@@ -53,7 +53,14 @@ module ActiveInteractor
53
53
  perform_in_order
54
54
  end
55
55
  end
56
- run_after_perform_callbacks_on_interactors if context.success?
56
+ end
57
+
58
+ def run_deferred_after_perform_callbacks_on_children
59
+ self.class.organized.each do |interface|
60
+ next unless interface.interactor_class.after_callbacks_deferred_when_organized
61
+
62
+ context.merge!(interface.execute_deferred_after_perform_callbacks(context))
63
+ end
57
64
  end
58
65
 
59
66
  private
@@ -100,14 +107,6 @@ module ActiveInteractor
100
107
  end
101
108
  merge_contexts(results.map(&:value))
102
109
  end
103
-
104
- def run_after_perform_callbacks_on_interactors
105
- self.class.organized.each do |interface|
106
- next unless interface.interactor_class.after_callbacks_deferred_when_organized
107
-
108
- context.merge!(interface.execute_deferred_after_perform_callbacks(context))
109
- end
110
- end
111
110
  end
112
111
  end
113
112
  end
@@ -16,7 +16,7 @@ module ActiveInteractor
16
16
 
17
17
  # The ActiveInterctor patch version number
18
18
  # @return [Integer] The ActiveInteractor patch version number
19
- PATCH = 1
19
+ PATCH = 2
20
20
 
21
21
  # The ActiveInterctor pre-release version
22
22
  # @return [String | nil] The ActiveInteractor pre-release version
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeinteractor
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.2.1
4
+ version: 1.2.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aaron Allen
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2022-09-26 00:00:00.000000000 Z
11
+ date: 2023-10-01 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activemodel
@@ -64,34 +64,6 @@ dependencies:
64
64
  - - "~>"
65
65
  - !ruby/object:Gem::Version
66
66
  version: '2.3'
67
- - !ruby/object:Gem::Dependency
68
- name: rake
69
- requirement: !ruby/object:Gem::Requirement
70
- requirements:
71
- - - "~>"
72
- - !ruby/object:Gem::Version
73
- version: '13.0'
74
- type: :development
75
- prerelease: false
76
- version_requirements: !ruby/object:Gem::Requirement
77
- requirements:
78
- - - "~>"
79
- - !ruby/object:Gem::Version
80
- version: '13.0'
81
- - !ruby/object:Gem::Dependency
82
- name: rspec
83
- requirement: !ruby/object:Gem::Requirement
84
- requirements:
85
- - - "~>"
86
- - !ruby/object:Gem::Version
87
- version: '3.11'
88
- type: :development
89
- prerelease: false
90
- version_requirements: !ruby/object:Gem::Requirement
91
- requirements:
92
- - - "~>"
93
- - !ruby/object:Gem::Version
94
- version: '3.11'
95
67
  description: |
96
68
  An implementation of the Command Pattern for Ruby with ActiveModel::Validations inspired by the interactor gem.
97
69
  Rich support for attributes, callbacks, and validations, and thread safe performance methods.
@@ -158,61 +130,15 @@ files:
158
130
  - lib/rails/generators/templates/interactor_spec.erb
159
131
  - lib/rails/generators/templates/interactor_test_unit.erb
160
132
  - lib/rails/generators/templates/organizer.erb
161
- - spec/active_interactor/base_spec.rb
162
- - spec/active_interactor/config_spec.rb
163
- - spec/active_interactor/context/base_spec.rb
164
- - spec/active_interactor/error_spec.rb
165
- - spec/active_interactor/interactor/perform/options_spec.rb
166
- - spec/active_interactor/interactor/worker_spec.rb
167
- - spec/active_interactor/organizer/base_spec.rb
168
- - spec/active_interactor/organizer/interactor_interface_collection_spec.rb
169
- - spec/active_interactor/organizer/interactor_interface_spec.rb
170
- - spec/active_interactor/version_spec.rb
171
- - spec/active_interactor_spec.rb
172
- - spec/integration/a_basic_interactor_spec.rb
173
- - spec/integration/a_basic_organizer_spec.rb
174
- - spec/integration/a_failing_interactor_spec.rb
175
- - spec/integration/active_record_integration_spec.rb
176
- - spec/integration/an_interactor_with_after_context_validation_callbacks_spec.rb
177
- - spec/integration/an_interactor_with_after_perform_callbacks_spec.rb
178
- - spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb
179
- - spec/integration/an_interactor_with_an_existing_context_class_spec.rb
180
- - spec/integration/an_interactor_with_around_perform_callbacks_spec.rb
181
- - spec/integration/an_interactor_with_around_rollback_callbacks_spec.rb
182
- - spec/integration/an_interactor_with_before_perform_callbacks_spec.rb
183
- - spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb
184
- - spec/integration/an_interactor_with_deferred_after_callbacks.rb
185
- - spec/integration/an_interactor_with_validations_on_called_spec.rb
186
- - spec/integration/an_interactor_with_validations_on_calling_spec.rb
187
- - spec/integration/an_interactor_with_validations_spec.rb
188
- - spec/integration/an_organizer_containing_organizer_with_after_callbacks_deferred_spec.rb
189
- - spec/integration/an_organizer_performing_in_parallel_spec.rb
190
- - spec/integration/an_organizer_with_after_callbacks_deferred_spec.rb
191
- - spec/integration/an_organizer_with_after_each_callbacks_spec.rb
192
- - spec/integration/an_organizer_with_all_perform_callbacks.rb
193
- - spec/integration/an_organizer_with_around_each_callbacks_spec.rb
194
- - spec/integration/an_organizer_with_before_each_callbacks_spec.rb
195
- - spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb
196
- - spec/integration/an_organizer_with_failing_nested_organizer_spec.rb
197
- - spec/integration/an_organizer_with_options_callbacks_spec.rb
198
- - spec/spec_helper.rb
199
- - spec/support/coverage.rb
200
- - spec/support/helpers/factories.rb
201
- - spec/support/shared_examples/a_class_that_extends_active_interactor_models_example.rb
202
- - spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb
203
- - spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb
204
- - spec/support/shared_examples/a_class_with_interactor_methods_example.rb
205
- - spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb
206
- - spec/support/spec_helpers.rb
207
133
  homepage: https://github.com/aaronmallen/activeinteractor
208
134
  licenses:
209
135
  - MIT
210
136
  metadata:
211
137
  bug_tracker_uri: https://github.com/aaronmallen/activeinteractor/issues
212
- changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.2.1/CHANGELOG.md
213
- documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.2.1
138
+ changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.2.2/CHANGELOG.md
139
+ documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.2.2
214
140
  hompage_uri: https://github.com/aaronmallen/activeinteractor
215
- source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.2.1
141
+ source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.2.2
216
142
  wiki_uri: https://github.com/aaronmallen/activeinteractor/wiki
217
143
  post_install_message:
218
144
  rdoc_options: []
@@ -229,54 +155,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
155
  - !ruby/object:Gem::Version
230
156
  version: '0'
231
157
  requirements: []
232
- rubygems_version: 3.0.3.1
158
+ rubygems_version: 3.1.6
233
159
  signing_key:
234
160
  specification_version: 4
235
161
  summary: Ruby interactors with ActiveModel::Validations
236
- test_files:
237
- - spec/integration/a_basic_organizer_spec.rb
238
- - spec/integration/an_organizer_with_failing_nested_organizer_spec.rb
239
- - spec/integration/an_organizer_with_after_callbacks_deferred_spec.rb
240
- - spec/integration/an_interactor_with_before_perform_callbacks_spec.rb
241
- - spec/integration/an_organizer_with_after_each_callbacks_spec.rb
242
- - spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb
243
- - spec/integration/active_record_integration_spec.rb
244
- - spec/integration/an_organizer_with_before_each_callbacks_spec.rb
245
- - spec/integration/an_organizer_with_all_perform_callbacks.rb
246
- - spec/integration/a_failing_interactor_spec.rb
247
- - spec/integration/an_organizer_with_around_each_callbacks_spec.rb
248
- - spec/integration/an_interactor_with_validations_on_called_spec.rb
249
- - spec/integration/an_interactor_with_after_context_validation_callbacks_spec.rb
250
- - spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb
251
- - spec/integration/an_organizer_performing_in_parallel_spec.rb
252
- - spec/integration/an_interactor_with_around_rollback_callbacks_spec.rb
253
- - spec/integration/an_interactor_with_an_existing_context_class_spec.rb
254
- - spec/integration/an_organizer_with_options_callbacks_spec.rb
255
- - spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb
256
- - spec/integration/an_interactor_with_validations_on_calling_spec.rb
257
- - spec/integration/an_interactor_with_validations_spec.rb
258
- - spec/integration/an_interactor_with_around_perform_callbacks_spec.rb
259
- - spec/integration/an_interactor_with_after_perform_callbacks_spec.rb
260
- - spec/integration/an_interactor_with_deferred_after_callbacks.rb
261
- - spec/integration/a_basic_interactor_spec.rb
262
- - spec/integration/an_organizer_containing_organizer_with_after_callbacks_deferred_spec.rb
263
- - spec/active_interactor_spec.rb
264
- - spec/support/helpers/factories.rb
265
- - spec/support/shared_examples/a_class_with_interactor_methods_example.rb
266
- - spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb
267
- - spec/support/shared_examples/a_class_that_extends_active_interactor_models_example.rb
268
- - spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb
269
- - spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb
270
- - spec/support/coverage.rb
271
- - spec/support/spec_helpers.rb
272
- - spec/active_interactor/base_spec.rb
273
- - spec/active_interactor/error_spec.rb
274
- - spec/active_interactor/config_spec.rb
275
- - spec/active_interactor/interactor/worker_spec.rb
276
- - spec/active_interactor/interactor/perform/options_spec.rb
277
- - spec/active_interactor/context/base_spec.rb
278
- - spec/active_interactor/version_spec.rb
279
- - spec/active_interactor/organizer/base_spec.rb
280
- - spec/active_interactor/organizer/interactor_interface_spec.rb
281
- - spec/active_interactor/organizer/interactor_interface_collection_spec.rb
282
- - spec/spec_helper.rb
162
+ test_files: []
@@ -1,85 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ActiveInteractor::Base do
6
- let(:interactor_class) { described_class }
7
-
8
- include_examples 'a class with interactor methods'
9
- include_examples 'a class with interactor callback methods'
10
- include_examples 'a class with interactor context methods'
11
-
12
- describe '.contextualize_with' do
13
- subject { described_class.contextualize_with(klass) }
14
-
15
- context 'with an class that does not exist' do
16
- let(:klass) { 'SomeClassThatDoesNotExist' }
17
-
18
- it { expect { subject }.to raise_error(ActiveInteractor::Error::InvalidContextClass) }
19
- end
20
-
21
- context 'with context class TestContext' do
22
- before { build_context }
23
-
24
- context 'when passed as a string' do
25
- let(:klass) { 'TestContext' }
26
-
27
- it 'is expected to assign the appropriate context class' do
28
- subject
29
- expect(described_class.context_class).to eq TestContext
30
- end
31
-
32
- # https://github.com/aaronmallen/activeinteractor/issues/168
33
- context 'when singularized' do
34
- let!(:singularized_class) { build_context('PlaceData') }
35
- let(:klass) { 'PlaceData' }
36
-
37
- it 'is expected to assign the appropriate context class' do
38
- subject
39
- expect(described_class.context_class).to eq PlaceData
40
- end
41
- end
42
- end
43
-
44
- context 'when passed as a symbol' do
45
- let(:klass) { :test_context }
46
-
47
- it 'is expected to assign the appropriate context class' do
48
- subject
49
- expect(described_class.context_class).to eq TestContext
50
- end
51
-
52
- # https://github.com/aaronmallen/activeinteractor/issues/168
53
- context 'when singularized' do
54
- let!(:singularized_class) { build_context('PlaceData') }
55
- let(:klass) { :place_data }
56
-
57
- it 'is expected to assign the appropriate context class' do
58
- subject
59
- expect(described_class.context_class).to eq PlaceData
60
- end
61
- end
62
- end
63
-
64
- context 'when passed as a constant' do
65
- let(:klass) { TestContext }
66
-
67
- it 'is expected to assign the appropriate context class' do
68
- subject
69
- expect(described_class.context_class).to eq TestContext
70
- end
71
-
72
- # https://github.com/aaronmallen/activeinteractor/issues/168
73
- context 'when singularized' do
74
- let!(:singularized_class) { build_context('PlaceData') }
75
- let(:klass) { PlaceData }
76
-
77
- it 'is expected to assign the appropriate context class' do
78
- subject
79
- expect(described_class.context_class).to eq PlaceData
80
- end
81
- end
82
- end
83
- end
84
- end
85
- end
@@ -1,17 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- RSpec.describe ActiveInteractor::Config do
6
- subject { described_class.new }
7
-
8
- it { is_expected.to respond_to :logger }
9
-
10
- describe '.defaults' do
11
- subject { described_class.defaults }
12
-
13
- it 'is expected to have attributes :logger => Logger.new' do
14
- expect(subject[:logger]).to be_a Logger
15
- end
16
- end
17
- end