activeinteractor 1.1.0 → 1.1.1
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 +9 -1
- data/lib/active_interactor/context/attributes.rb +4 -4
- data/lib/active_interactor/version.rb +1 -1
- data/spec/integration/a_basic_organizer_spec.rb +119 -0
- metadata +31 -31
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 18cf10a86ec48171ff40670464a016626fed857a9f429f39a66cecd5e5d89ce8
|
4
|
+
data.tar.gz: f53205376b409a3c4a589b73c3f45dd5f56264c077d96e8af64d28918da0ea91
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 52ae6e7c4a6a595ee8ef7bdecf5b496cd399f60ab79b0b7806b690661b1a8a82ce05438026a2a6a1e6177688077057209a2aad546f36bb57fb16ba87948fe3c8
|
7
|
+
data.tar.gz: d6510e42ddb2bb1b639fe36b7ec4a9df936519be1cce3d6c7000ecc05578f9609118b50131a82e19b725ff5dfa21597f00b23cabe16bbb5a153dc60bded0f716
|
data/CHANGELOG.md
CHANGED
@@ -7,6 +7,13 @@ and this project adheres to [Semantic Versioning].
|
|
7
7
|
|
8
8
|
## [Unreleased]
|
9
9
|
|
10
|
+
## [v1.1.1] - 2020-10-21
|
11
|
+
|
12
|
+
### Fixed
|
13
|
+
|
14
|
+
- [\#267](https://github.com/aaronmallen/activeinteractor/pull/267) Allow default attributes to propagate to
|
15
|
+
sibling/child interactors
|
16
|
+
|
10
17
|
## [v1.1.0] - 2020-10-04
|
11
18
|
|
12
19
|
### Added
|
@@ -212,7 +219,8 @@ and this project adheres to [Semantic Versioning].
|
|
212
219
|
|
213
220
|
<!-- versions -->
|
214
221
|
|
215
|
-
[Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.
|
222
|
+
[Unreleased]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.1...HEAD
|
223
|
+
[v1.1.1]: https://github.com/aaronmallen/activeinteractor/compare/v1.1.0...v1.1.1
|
216
224
|
[v1.1.0]: https://github.com/aaronmallen/activeinteractor/compare/v1.0.5...v1.1.0
|
217
225
|
[v1.0.5]: https://github.com/aaronmallen/activeinteractor/compare/v1.0.4...v1.0.5
|
218
226
|
[v1.0.4]: https://github.com/aaronmallen/activeinteractor/compare/v1.0.3...v1.0.4
|
@@ -79,7 +79,7 @@ module ActiveInteractor
|
|
79
79
|
def []=(name, value)
|
80
80
|
public_send("#{name}=", value)
|
81
81
|
|
82
|
-
super
|
82
|
+
super unless @table.nil?
|
83
83
|
end
|
84
84
|
|
85
85
|
# Get values defined on the instance of {Base context} whose keys are defined on the {Base context} class'
|
@@ -132,7 +132,7 @@ module ActiveInteractor
|
|
132
132
|
copy_flags!(context)
|
133
133
|
|
134
134
|
merged_context_attributes(context).each_pair do |key, value|
|
135
|
-
|
135
|
+
self[key] = value unless value.nil?
|
136
136
|
end
|
137
137
|
self
|
138
138
|
end
|
@@ -170,8 +170,8 @@ module ActiveInteractor
|
|
170
170
|
def merge_attribute_values(context)
|
171
171
|
return unless context
|
172
172
|
|
173
|
-
context.each_pair do |key, value|
|
174
|
-
|
173
|
+
attributes.compact.merge(context).each_pair do |key, value|
|
174
|
+
self[key] = value
|
175
175
|
end
|
176
176
|
end
|
177
177
|
end
|
@@ -224,5 +224,124 @@ RSpec.describe 'A basic organizer', type: :integration do
|
|
224
224
|
end
|
225
225
|
end
|
226
226
|
end
|
227
|
+
|
228
|
+
context 'when passing default attributes on the organizer and its interactors' do
|
229
|
+
let!(:test_organizer_context_class) do
|
230
|
+
build_context('TestOrganizerContext') do
|
231
|
+
attribute :foo
|
232
|
+
attribute :baz
|
233
|
+
attribute :zoo, default: 'zoo'
|
234
|
+
attribute :taz, default: 'taz0'
|
235
|
+
end
|
236
|
+
end
|
237
|
+
|
238
|
+
let!(:test_interactor_3_context_class) do
|
239
|
+
build_context('TestInteractor3Context') do
|
240
|
+
attribute :foo
|
241
|
+
attribute :bar, default: 'bar'
|
242
|
+
attribute :baz, default: 'baz'
|
243
|
+
attribute :zoo
|
244
|
+
attribute :taz, default: 'taz3'
|
245
|
+
end
|
246
|
+
end
|
247
|
+
|
248
|
+
let!(:test_interactor_4_context_class) do
|
249
|
+
build_context('TestInteractor4Context') do
|
250
|
+
attribute :foo
|
251
|
+
attribute :bar, default: 'bar'
|
252
|
+
attribute :baz
|
253
|
+
end
|
254
|
+
end
|
255
|
+
|
256
|
+
let!(:test_interactor_3) do
|
257
|
+
build_interactor('TestInteractor3') do
|
258
|
+
def perform
|
259
|
+
context.bar = 'bar'
|
260
|
+
context.taz_is_set_at_3 = (context.taz == 'taz')
|
261
|
+
context.baz_is_set_at_3 = (context.baz == 'baz')
|
262
|
+
context.zoo_is_set_at_3 = (context.zoo == 'zoo')
|
263
|
+
end
|
264
|
+
end
|
265
|
+
end
|
266
|
+
|
267
|
+
let!(:test_interactor_4) do
|
268
|
+
build_interactor('TestInteractor4') do
|
269
|
+
def perform
|
270
|
+
context.taz_is_set_at_4 = (context.taz == 'taz')
|
271
|
+
context.baz_is_set_at_4 = (context.baz == 'baz')
|
272
|
+
context.zoo_is_set_at_4 = (context.zoo == 'zoo')
|
273
|
+
end
|
274
|
+
end
|
275
|
+
end
|
276
|
+
|
277
|
+
let!(:interactor_class) do
|
278
|
+
build_organizer('TestOrganizer') do
|
279
|
+
organize TestInteractor3, TestInteractor4
|
280
|
+
end
|
281
|
+
end
|
282
|
+
|
283
|
+
describe '.context_class' do
|
284
|
+
describe 'TestOrganizer' do
|
285
|
+
subject { interactor_class.context_class }
|
286
|
+
|
287
|
+
it { is_expected.to eq TestOrganizerContext }
|
288
|
+
it { is_expected.to be < ActiveInteractor::Context::Base }
|
289
|
+
end
|
290
|
+
|
291
|
+
describe 'TestInteractor3' do
|
292
|
+
subject { test_interactor_3.context_class }
|
293
|
+
|
294
|
+
it { is_expected.to eq TestInteractor3Context }
|
295
|
+
it { is_expected.to be < ActiveInteractor::Context::Base }
|
296
|
+
end
|
297
|
+
|
298
|
+
describe 'TestInteractor4' do
|
299
|
+
subject { test_interactor_4.context_class }
|
300
|
+
|
301
|
+
it { is_expected.to eq TestInteractor4Context }
|
302
|
+
it { is_expected.to be < ActiveInteractor::Context::Base }
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
describe '.perform' do
|
307
|
+
subject(:result) { interactor_class.perform(context_attributes) }
|
308
|
+
|
309
|
+
context 'when inputs are not defined' do
|
310
|
+
let(:context_attributes) { {} }
|
311
|
+
|
312
|
+
it { is_expected.to have_attributes(foo: nil, bar: 'bar', baz: 'baz') }
|
313
|
+
end
|
314
|
+
|
315
|
+
context 'when [:foo] is defined' do
|
316
|
+
let(:context_attributes) { { foo: 'foo' } }
|
317
|
+
|
318
|
+
it { is_expected.to have_attributes(foo: 'foo', bar: 'bar', baz: 'baz') }
|
319
|
+
end
|
320
|
+
|
321
|
+
context 'when [:taz] is defined' do
|
322
|
+
let(:context_attributes) { { taz: 'taz' } }
|
323
|
+
|
324
|
+
it { is_expected.to have_attributes(taz: 'taz', taz_is_set_at_3: true, taz_is_set_at_4: true) }
|
325
|
+
end
|
326
|
+
|
327
|
+
context 'when [:bar] is nil' do
|
328
|
+
let(:context_attributes) { { bar: nil } }
|
329
|
+
|
330
|
+
it { is_expected.to have_attributes(foo: nil, bar: 'bar', baz: 'baz') }
|
331
|
+
end
|
332
|
+
|
333
|
+
context 'when [:baz] is nil' do
|
334
|
+
let(:context_attributes) { {} }
|
335
|
+
|
336
|
+
it { is_expected.to have_attributes(baz: 'baz', baz_is_set_at_3: true, baz_is_set_at_4: true) }
|
337
|
+
end
|
338
|
+
|
339
|
+
context 'when [:zoo] is nil' do
|
340
|
+
let(:context_attributes) { {} }
|
341
|
+
|
342
|
+
it { is_expected.to have_attributes(zoo: 'zoo', zoo_is_set_at_3: true, zoo_is_set_at_4: true) }
|
343
|
+
end
|
344
|
+
end
|
345
|
+
end
|
227
346
|
end
|
228
347
|
end
|
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.1.
|
4
|
+
version: 1.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Aaron Allen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-10-
|
11
|
+
date: 2020-10-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activemodel
|
@@ -203,10 +203,10 @@ licenses:
|
|
203
203
|
- MIT
|
204
204
|
metadata:
|
205
205
|
bug_tracker_uri: https://github.com/aaronmallen/activeinteractor/issues
|
206
|
-
changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.1.
|
207
|
-
documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.1.
|
206
|
+
changelog_uri: https://github.com/aaronmallen/activeinteractor/blob/v1.1.1/CHANGELOG.md
|
207
|
+
documentation_uri: https://www.rubydoc.info/gems/activeinteractor/1.1.1
|
208
208
|
hompage_uri: https://github.com/aaronmallen/activeinteractor
|
209
|
-
source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.1.
|
209
|
+
source_code_uri: https://github.com/aaronmallen/activeinteractor/tree/v1.1.1
|
210
210
|
wiki_uri: https://github.com/aaronmallen/activeinteractor/wiki
|
211
211
|
post_install_message:
|
212
212
|
rdoc_options: []
|
@@ -229,42 +229,42 @@ specification_version: 4
|
|
229
229
|
summary: Ruby interactors with ActiveModel::Validations
|
230
230
|
test_files:
|
231
231
|
- spec/support/shared_examples/a_class_that_extends_active_interactor_models_example.rb
|
232
|
-
- spec/support/shared_examples/a_class_with_interactor_methods_example.rb
|
233
232
|
- spec/support/shared_examples/a_class_with_interactor_context_methods_example.rb
|
234
|
-
- spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb
|
235
233
|
- spec/support/shared_examples/a_class_with_interactor_callback_methods_example.rb
|
234
|
+
- spec/support/shared_examples/a_class_with_interactor_methods_example.rb
|
235
|
+
- spec/support/shared_examples/a_class_with_organizer_callback_methods_example.rb
|
236
236
|
- spec/support/spec_helpers.rb
|
237
237
|
- spec/support/helpers/factories.rb
|
238
|
-
- spec/
|
239
|
-
- spec/
|
240
|
-
- spec/
|
241
|
-
- spec/
|
242
|
-
- spec/
|
243
|
-
- spec/
|
238
|
+
- spec/active_interactor/organizer/interactor_interface_spec.rb
|
239
|
+
- spec/active_interactor/organizer/interactor_interface_collection_spec.rb
|
240
|
+
- spec/active_interactor/organizer/base_spec.rb
|
241
|
+
- spec/active_interactor/config_spec.rb
|
242
|
+
- spec/active_interactor/interactor/perform/options_spec.rb
|
243
|
+
- spec/active_interactor/interactor/worker_spec.rb
|
244
|
+
- spec/active_interactor/error_spec.rb
|
245
|
+
- spec/active_interactor/base_spec.rb
|
246
|
+
- spec/active_interactor/context/base_spec.rb
|
244
247
|
- spec/integration/an_interactor_with_validations_spec.rb
|
248
|
+
- spec/integration/a_basic_interactor_spec.rb
|
249
|
+
- spec/integration/active_record_integration_spec.rb
|
250
|
+
- spec/integration/an_organizer_performing_in_parallel_spec.rb
|
251
|
+
- spec/integration/an_organizer_with_failing_nested_organizer_spec.rb
|
252
|
+
- spec/integration/an_interactor_with_after_context_validation_callbacks_spec.rb
|
245
253
|
- spec/integration/an_interactor_with_an_existing_context_class_spec.rb
|
246
|
-
- spec/integration/an_organizer_with_around_each_callbacks_spec.rb
|
247
|
-
- spec/integration/an_interactor_with_validations_on_called_spec.rb
|
248
|
-
- spec/integration/an_interactor_with_around_perform_callbacks_spec.rb
|
249
254
|
- spec/integration/an_interactor_with_before_rollback_callbacks_spec.rb
|
250
|
-
- spec/integration/
|
255
|
+
- spec/integration/an_organizer_with_before_each_callbacks_spec.rb
|
256
|
+
- spec/integration/an_interactor_with_validations_on_calling_spec.rb
|
257
|
+
- spec/integration/an_organizer_with_options_callbacks_spec.rb
|
251
258
|
- spec/integration/an_interactor_with_around_rollback_callbacks_spec.rb
|
259
|
+
- spec/integration/an_interactor_with_validations_on_called_spec.rb
|
252
260
|
- spec/integration/an_interactor_with_after_perform_callbacks_spec.rb
|
253
|
-
- spec/integration/an_interactor_with_after_context_validation_callbacks_spec.rb
|
254
|
-
- spec/integration/an_organizer_with_after_each_callbacks_spec.rb
|
255
|
-
- spec/integration/active_record_integration_spec.rb
|
256
261
|
- spec/integration/a_failing_interactor_spec.rb
|
257
|
-
- spec/integration/
|
258
|
-
- spec/integration/
|
262
|
+
- spec/integration/an_organizer_with_conditionally_organized_interactors_spec.rb
|
263
|
+
- spec/integration/an_interactor_with_around_perform_callbacks_spec.rb
|
264
|
+
- spec/integration/an_organizer_with_around_each_callbacks_spec.rb
|
259
265
|
- spec/integration/an_interactor_with_after_rollback_callbacks_spec.rb
|
260
|
-
- spec/
|
261
|
-
- spec/
|
262
|
-
- spec/
|
263
|
-
- spec/active_interactor/config_spec.rb
|
264
|
-
- spec/active_interactor/error_spec.rb
|
265
|
-
- spec/active_interactor/base_spec.rb
|
266
|
-
- spec/active_interactor/organizer/interactor_interface_collection_spec.rb
|
267
|
-
- spec/active_interactor/organizer/base_spec.rb
|
268
|
-
- spec/active_interactor/organizer/interactor_interface_spec.rb
|
266
|
+
- spec/integration/an_organizer_with_after_each_callbacks_spec.rb
|
267
|
+
- spec/integration/an_interactor_with_before_perform_callbacks_spec.rb
|
268
|
+
- spec/integration/a_basic_organizer_spec.rb
|
269
269
|
- spec/spec_helper.rb
|
270
270
|
- spec/active_interactor_spec.rb
|