trailblazer-operation 0.10.1 → 0.11.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/ci.yml +2 -2
- data/CHANGES.md +10 -0
- data/lib/trailblazer/operation/class_dependencies.rb +1 -1
- data/lib/trailblazer/operation/public_call.rb +24 -14
- data/lib/trailblazer/operation/railway.rb +13 -7
- data/lib/trailblazer/operation/version.rb +1 -1
- data/lib/trailblazer/operation/wtf.rb +11 -0
- data/lib/trailblazer/operation.rb +2 -2
- data/test/call_test.rb +32 -10
- data/test/class_dependencies_test.rb +8 -4
- data/test/docs/autogenerated/activity_basics_test.rb +72 -0
- data/test/docs/autogenerated/composable_variable_mapping_test.rb +880 -0
- data/test/docs/autogenerated/fast_track_layout_test.rb +76 -0
- data/test/docs/autogenerated/mechanics_test.rb +382 -0
- data/test/docs/autogenerated/sequence_options_test.rb +202 -0
- data/test/docs/autogenerated/subprocess_test.rb +257 -0
- data/test/docs/autogenerated/wiring_api_test.rb +435 -0
- data/test/docs/developer_test.rb +27 -0
- data/test/docs/public_call_monkeypatching_test.rb +96 -0
- data/test/docs/result_test.rb +38 -0
- data/test/docs/step_dsl_test.rb +93 -0
- data/test/operation_test.rb +53 -13
- data/test/result_test.rb +1 -1
- data/test/test_helper.rb +17 -5
- data/test/trace_test.rb +3 -43
- data/trailblazer-operation.gemspec +2 -1
- metadata +42 -23
- data/lib/trailblazer/operation/trace.rb +0 -67
- data/test/callable_test.rb +0 -147
- data/test/docs/doormat_test.rb +0 -190
- data/test/docs/macaroni_test.rb +0 -31
- data/test/skill_test.rb +0 -66
- data/test/wire_test.rb +0 -113
- data/test/wiring/defaults_test.rb +0 -193
- data/test/wiring/subprocess_test.rb +0 -70
@@ -0,0 +1,76 @@
|
|
1
|
+
# THIS FILE IS AUTOGENERATED FROM trailblazer-activity-dsl-linear/test/docs/fast_track_layout_test.rb
|
2
|
+
require "test_helper"
|
3
|
+
|
4
|
+
class FastTrack_Layout_Passfast_DocTest < Minitest::Spec
|
5
|
+
Memo = Class.new
|
6
|
+
it do
|
7
|
+
#:ft-passfast
|
8
|
+
module Memo::Operation
|
9
|
+
class Create < Trailblazer::Operation
|
10
|
+
step :validate, pass_fast: true
|
11
|
+
step :save
|
12
|
+
fail :handle_errors
|
13
|
+
#~mod
|
14
|
+
include T.def_steps(:validate, :handle_errors, :save)
|
15
|
+
#~mod end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
#:ft-passfast end
|
19
|
+
|
20
|
+
assert_invoke Memo::Operation::Create, terminus: :pass_fast, seq: "[:validate]"
|
21
|
+
assert_invoke Memo::Operation::Create, validate: false, seq: "[:validate, :handle_errors]", terminus: :failure
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
class FastTrack_Layout_Failfast_DocTest < Minitest::Spec
|
26
|
+
Memo = Class.new
|
27
|
+
it do
|
28
|
+
#:ft-failfast
|
29
|
+
module Memo::Operation
|
30
|
+
class Create < Trailblazer::Operation
|
31
|
+
step :validate, fail_fast: true
|
32
|
+
step :save
|
33
|
+
fail :handle_errors
|
34
|
+
#~mod
|
35
|
+
include T.def_steps(:validate, :handle_errors, :save)
|
36
|
+
#~mod end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
#:ft-failfast end
|
40
|
+
|
41
|
+
assert_invoke Memo::Operation::Create, terminus: :fail_fast, seq: "[:validate]", validate: false
|
42
|
+
assert_invoke Memo::Operation::Create, seq: "[:validate, :save]"
|
43
|
+
assert_invoke Memo::Operation::Create, save: false, seq: "[:validate, :save, :handle_errors]", terminus: :failure
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
class FastTrack_Layout_FastTrack_DocTest < Minitest::Spec
|
48
|
+
Memo = Class.new
|
49
|
+
it do
|
50
|
+
#:ft-fasttrack
|
51
|
+
class Create < Trailblazer::Operation
|
52
|
+
module Memo::Operation
|
53
|
+
class Create < Trailblazer::Operation
|
54
|
+
step :validate, fast_track: true
|
55
|
+
step :save
|
56
|
+
fail :handle_errors
|
57
|
+
|
58
|
+
def validate(ctx, params:, **)
|
59
|
+
return Railway.fail_fast! if params.nil?
|
60
|
+
|
61
|
+
params.key?(:memo)
|
62
|
+
end
|
63
|
+
#~mod
|
64
|
+
include T.def_steps(:validate, :handle_errors, :save)
|
65
|
+
#~mod end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
#:ft-fasttrack end
|
70
|
+
|
71
|
+
|
72
|
+
assert_invoke Memo::Operation::Create, terminus: :fail_fast, seq: "[]", params: nil
|
73
|
+
assert_invoke Memo::Operation::Create, seq: "[:save]", params: {memo: nil}
|
74
|
+
assert_invoke Memo::Operation::Create, seq: "[:handle_errors]", terminus: :failure, params: {}
|
75
|
+
end
|
76
|
+
end
|
@@ -0,0 +1,382 @@
|
|
1
|
+
# THIS FILE IS AUTOGENERATED FROM trailblazer-activity-dsl-linear/test/docs/mechanics_test.rb
|
2
|
+
require "test_helper"
|
3
|
+
|
4
|
+
module Y
|
5
|
+
class DocsMechanicsTest < Minitest::Spec
|
6
|
+
Memo = Module.new
|
7
|
+
it "what" do
|
8
|
+
#:instance-method
|
9
|
+
module Memo::Operation
|
10
|
+
class Create < Trailblazer::Operation
|
11
|
+
step :validate
|
12
|
+
|
13
|
+
#~meths
|
14
|
+
def validate(ctx, params:, **)
|
15
|
+
params.key?(:memo) ? true : false # return value matters!
|
16
|
+
end
|
17
|
+
#~meths end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
#:instance-method end
|
21
|
+
|
22
|
+
#:instance-method-call
|
23
|
+
result = Memo::Operation::Create.call(params: {memo: nil})
|
24
|
+
#:instance-method-call end
|
25
|
+
assert_equal result.success?, true
|
26
|
+
|
27
|
+
#:instance-method-implicit-call
|
28
|
+
result = Memo::Operation::Create.(params: {memo: nil})
|
29
|
+
# #:instance-method-implicit-call end
|
30
|
+
assert_equal result.success?, true
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
class ReadfromCtx_DocsMechanicsTest < Minitest::Spec
|
36
|
+
Memo = Module.new
|
37
|
+
it "what" do
|
38
|
+
#:ctx-read
|
39
|
+
module Memo::Operation
|
40
|
+
class Create < Trailblazer::Operation
|
41
|
+
step :validate
|
42
|
+
#~meths
|
43
|
+
step :save
|
44
|
+
|
45
|
+
def save(*); true; end
|
46
|
+
#~meths end
|
47
|
+
def validate(ctx, **)
|
48
|
+
p ctx[:params] #=> {:memo=>nil}
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
#:ctx-read end
|
53
|
+
|
54
|
+
#:ctx-read-call
|
55
|
+
result = Memo::Operation::Create.(params: {memo: nil})
|
56
|
+
#:ctx-read-call end
|
57
|
+
assert_equal result.success?, true
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
class ReadfromCtxKwargs_DocsMechanicsTest < Minitest::Spec
|
62
|
+
Memo = Module.new
|
63
|
+
it "what" do
|
64
|
+
module Memo::Operation
|
65
|
+
class Create < Trailblazer::Operation
|
66
|
+
step :validate
|
67
|
+
#~meths
|
68
|
+
step :save
|
69
|
+
|
70
|
+
def save(*); true; end
|
71
|
+
#~meths end
|
72
|
+
#:ctx-read-kwargs
|
73
|
+
def validate(ctx, params:, **)
|
74
|
+
p params #=> {:memo=>nil}
|
75
|
+
end
|
76
|
+
#:ctx-read-kwargs end
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
result = Memo::Operation::Create.(params: {memo: nil})
|
81
|
+
assert_equal result.success?, true
|
82
|
+
|
83
|
+
user = Object
|
84
|
+
assert_raises ArgumentError do
|
85
|
+
#:kwargs-error
|
86
|
+
result = Memo::Operation::Create.(current_user: user)
|
87
|
+
#=> ArgumentError: missing keyword: :params
|
88
|
+
# memo/operation/create.rb:9:in `validate'
|
89
|
+
#:kwargs-error end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
94
|
+
class WriteToCtx_DocsMechanicsTest < Minitest::Spec
|
95
|
+
class Memo
|
96
|
+
def initialize(*); end
|
97
|
+
end
|
98
|
+
it "what" do
|
99
|
+
#:ctx-write-read
|
100
|
+
module Memo::Operation
|
101
|
+
class Create < Trailblazer::Operation
|
102
|
+
step :validate
|
103
|
+
step :save # sets ctx[:model]
|
104
|
+
step :notify
|
105
|
+
#~body
|
106
|
+
#~meths
|
107
|
+
def validate(ctx, params:, **)
|
108
|
+
true
|
109
|
+
end
|
110
|
+
|
111
|
+
def send_email(*)
|
112
|
+
true
|
113
|
+
end
|
114
|
+
#~meths end
|
115
|
+
#:ctx-write
|
116
|
+
def save(ctx, params:, **)
|
117
|
+
ctx[:model] = Memo.new(params[:memo])
|
118
|
+
end
|
119
|
+
#~body end
|
120
|
+
#:ctx-write end
|
121
|
+
def notify(ctx, model:, **)
|
122
|
+
send_email(model)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
#:ctx-write-read end
|
127
|
+
|
128
|
+
#:result-read
|
129
|
+
result = Memo::Operation::Create.(params: {memo: {content: "remember that"}})
|
130
|
+
|
131
|
+
result[:model] #=> #<Memo id: 1, ...>
|
132
|
+
#:result-read end
|
133
|
+
|
134
|
+
#:result-success
|
135
|
+
puts result.success? #=> true
|
136
|
+
#:result-success end
|
137
|
+
|
138
|
+
assert_equal result[:model].class, Memo
|
139
|
+
assert_equal result.success?, true
|
140
|
+
|
141
|
+
user = Object
|
142
|
+
assert_raises ArgumentError do
|
143
|
+
#:kwargs-error
|
144
|
+
result = Memo::Operation::Create.(current_user: user)
|
145
|
+
#=> ArgumentError: missing keyword: :params
|
146
|
+
# memo/operation/create.rb:9:in `validate'
|
147
|
+
#:kwargs-error end
|
148
|
+
end
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
152
|
+
class ReturnValueSuccess_DocsMechanicsTest < Minitest::Spec
|
153
|
+
Memo = Module.new
|
154
|
+
it "what" do
|
155
|
+
module Memo::Operation
|
156
|
+
class Create < Trailblazer::Operation
|
157
|
+
step :validate
|
158
|
+
#~meths
|
159
|
+
step :save
|
160
|
+
|
161
|
+
def save(*); true; end
|
162
|
+
#~meths end
|
163
|
+
#:return-success
|
164
|
+
def validate(ctx, params:, **)
|
165
|
+
params.key?(:memo) # => true/false
|
166
|
+
end
|
167
|
+
#:return-success end
|
168
|
+
end
|
169
|
+
end
|
170
|
+
|
171
|
+
result = Memo::Operation::Create.(params: {memo: nil})
|
172
|
+
assert_equal result.success?, true
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
176
|
+
class ReturnValueFailure_DocsMechanicsTest < Minitest::Spec
|
177
|
+
Memo = Module.new
|
178
|
+
it "what" do
|
179
|
+
module Memo::Operation
|
180
|
+
class Create < Trailblazer::Operation
|
181
|
+
step :validate
|
182
|
+
#~meths
|
183
|
+
step :save
|
184
|
+
|
185
|
+
def save(*); true; end
|
186
|
+
#~meths end
|
187
|
+
#:return-failure
|
188
|
+
def validate(ctx, params:, **)
|
189
|
+
nil
|
190
|
+
end
|
191
|
+
#:return-failure end
|
192
|
+
end
|
193
|
+
end
|
194
|
+
|
195
|
+
result = Memo::Operation::Create.(params: {memo: nil})
|
196
|
+
assert_equal result.success?, false
|
197
|
+
end
|
198
|
+
end
|
199
|
+
|
200
|
+
class ReturnSignal_DocsMechanicsTest < Minitest::Spec
|
201
|
+
Memo = Module.new
|
202
|
+
it "what" do
|
203
|
+
#:signal-operation
|
204
|
+
module Memo::Operation
|
205
|
+
class Create < Trailblazer::Operation
|
206
|
+
class NetworkError < Trailblazer::Activity::Signal
|
207
|
+
end
|
208
|
+
#~meths
|
209
|
+
#:signal-steps
|
210
|
+
step :validate
|
211
|
+
step :save
|
212
|
+
left :handle_errors
|
213
|
+
step :notify,
|
214
|
+
Output(NetworkError, :network_error) => End(:network_error)
|
215
|
+
#:signal-steps end
|
216
|
+
def save(ctx, **)
|
217
|
+
ctx[:model] = Object
|
218
|
+
end
|
219
|
+
def validate(ctx, params:, **)
|
220
|
+
true
|
221
|
+
end
|
222
|
+
def send_email(model)
|
223
|
+
true
|
224
|
+
end
|
225
|
+
def check_network(params)
|
226
|
+
! params[:network_broken]
|
227
|
+
end
|
228
|
+
|
229
|
+
#:return-signal
|
230
|
+
def notify(ctx, model:, params:, **)
|
231
|
+
return NetworkError unless check_network(params)
|
232
|
+
|
233
|
+
send_email(model)
|
234
|
+
end
|
235
|
+
#:return-signal end
|
236
|
+
#~meths end
|
237
|
+
end
|
238
|
+
end
|
239
|
+
#:signal-operation end
|
240
|
+
|
241
|
+
result = Memo::Operation::Create.(params: {memo: nil, network_broken: false})
|
242
|
+
assert_equal result.success?, true
|
243
|
+
|
244
|
+
#:terminus
|
245
|
+
result = Memo::Operation::Create.(params: {memo: nil, network_broken: true})
|
246
|
+
|
247
|
+
result.terminus.to_h[:semantic] #=> :network_error
|
248
|
+
#:terminus end
|
249
|
+
assert_equal result.success?, false
|
250
|
+
assert_equal result.terminus.to_h[:semantic], :network_error
|
251
|
+
|
252
|
+
#:terminus-subprocess
|
253
|
+
module Endpoint
|
254
|
+
class API < Trailblazer::Operation
|
255
|
+
step Subprocess(Memo::Operation::Create),
|
256
|
+
Output(:network_error) => Track(:failure)
|
257
|
+
# ...
|
258
|
+
end
|
259
|
+
end
|
260
|
+
#:terminus-subprocess end
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
class Classmethod_DocsMechanicsTest < Minitest::Spec
|
265
|
+
Memo = Module.new
|
266
|
+
it "what" do
|
267
|
+
#:class-method
|
268
|
+
module Memo::Operation
|
269
|
+
class Create < Trailblazer::Operation
|
270
|
+
#~meths
|
271
|
+
# Define {Memo::Operation::Create.validate}
|
272
|
+
def self.validate(ctx, params:, **)
|
273
|
+
params.key?(:memo) ? true : false # return value matters!
|
274
|
+
end
|
275
|
+
#~meths end
|
276
|
+
|
277
|
+
step method(:validate)
|
278
|
+
end
|
279
|
+
end
|
280
|
+
#:class-method end
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
class Module_Classmethod_DocsMechanicsTest < Minitest::Spec
|
285
|
+
Memo = Module.new
|
286
|
+
it "what" do
|
287
|
+
#:module-step
|
288
|
+
# Reusable steps in a module.
|
289
|
+
module Steps
|
290
|
+
def self.validate(ctx, params:, **)
|
291
|
+
params.key?(:memo) ? true : false # return value matters!
|
292
|
+
end
|
293
|
+
end
|
294
|
+
#:module-step end
|
295
|
+
|
296
|
+
#:module-method
|
297
|
+
module Memo::Operation
|
298
|
+
class Create < Trailblazer::Operation
|
299
|
+
step Steps.method(:validate)
|
300
|
+
end
|
301
|
+
end
|
302
|
+
#:module-method end
|
303
|
+
end
|
304
|
+
end
|
305
|
+
|
306
|
+
class Callable_DocsMechanicsTest < Minitest::Spec
|
307
|
+
Memo = Module.new
|
308
|
+
it "what" do
|
309
|
+
#:callable-step
|
310
|
+
module Validate
|
311
|
+
def self.call(ctx, params:, **)
|
312
|
+
valid?(params) ? true : false # return value matters!
|
313
|
+
end
|
314
|
+
|
315
|
+
def valid?(params)
|
316
|
+
params.key?(:memo)
|
317
|
+
end
|
318
|
+
end
|
319
|
+
#:callable-step end
|
320
|
+
|
321
|
+
#:callable-method
|
322
|
+
module Memo::Operation
|
323
|
+
class Create < Trailblazer::Operation
|
324
|
+
step Validate
|
325
|
+
end
|
326
|
+
end
|
327
|
+
#:callable-method end
|
328
|
+
end
|
329
|
+
end
|
330
|
+
|
331
|
+
class Lambda_DocsMechanicsTest < Minitest::Spec
|
332
|
+
Memo = Module.new
|
333
|
+
it "what" do
|
334
|
+
#:lambda-step
|
335
|
+
module Memo::Operation
|
336
|
+
class Create < Trailblazer::Operation
|
337
|
+
step ->(ctx, params:, **) { p params.inspect }
|
338
|
+
end
|
339
|
+
end
|
340
|
+
#:lambda-step end
|
341
|
+
end
|
342
|
+
end
|
343
|
+
|
344
|
+
class Inheritance_DocsMechanicsTest < Minitest::Spec
|
345
|
+
Memo = Module.new
|
346
|
+
it "what" do
|
347
|
+
#:inherit-create
|
348
|
+
module Memo::Operation
|
349
|
+
class Create < Trailblazer::Operation
|
350
|
+
step :create_model
|
351
|
+
step :validate
|
352
|
+
step :save
|
353
|
+
#~meths
|
354
|
+
include T.def_steps(:create_model, :validate, :save)
|
355
|
+
#~meths end
|
356
|
+
end
|
357
|
+
end
|
358
|
+
#:inherit-create end
|
359
|
+
|
360
|
+
#:inherit-update-empty
|
361
|
+
module Memo::Operation
|
362
|
+
class Update < Create
|
363
|
+
end
|
364
|
+
end
|
365
|
+
#:inherit-update-empty end
|
366
|
+
|
367
|
+
#:inherit-update
|
368
|
+
module Memo::Operation
|
369
|
+
class Update < Create
|
370
|
+
step :find_model, replace: :create_model
|
371
|
+
#~meths
|
372
|
+
include T.def_steps(:find_model)
|
373
|
+
#~meths end
|
374
|
+
end
|
375
|
+
end
|
376
|
+
#:inherit-update end
|
377
|
+
|
378
|
+
assert_invoke Memo::Operation::Create, seq: "[:create_model, :validate, :save]"
|
379
|
+
assert_invoke Memo::Operation::Update, seq: "[:find_model, :validate, :save]"
|
380
|
+
end
|
381
|
+
end
|
382
|
+
|
@@ -0,0 +1,202 @@
|
|
1
|
+
# THIS FILE IS AUTOGENERATED FROM trailblazer-activity-dsl-linear/test/docs/sequence_options_test.rb
|
2
|
+
require "test_helper"
|
3
|
+
# require "trailblazer/developer"
|
4
|
+
|
5
|
+
module A
|
6
|
+
class Id_DocSeqOptionsTest < Minitest::Spec
|
7
|
+
Memo = Struct.new(:text)
|
8
|
+
|
9
|
+
#:id
|
10
|
+
module Memo::Operation
|
11
|
+
class Create < Trailblazer::Operation
|
12
|
+
step :validate
|
13
|
+
step :save, id: :save_the_world
|
14
|
+
step :notify
|
15
|
+
#~meths
|
16
|
+
include T.def_steps(:validate, :save, :notify)
|
17
|
+
#~meths end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
#:id end
|
21
|
+
|
22
|
+
it ":id shows up in introspect" do
|
23
|
+
=begin
|
24
|
+
output =
|
25
|
+
#:id-inspect
|
26
|
+
Trailblazer::Developer.railway(Memo::Operation::Create)
|
27
|
+
#=> [>validate,>save_the_world,>notify]
|
28
|
+
#:id-inspect end
|
29
|
+
=end
|
30
|
+
|
31
|
+
#~ignore end
|
32
|
+
|
33
|
+
assert Trailblazer::Activity::Introspect.Nodes(Memo::Operation::Create, id: :save_the_world)
|
34
|
+
#:id-introspect
|
35
|
+
puts Trailblazer::Activity::Introspect.Nodes(Memo::Operation::Create, id: :save_the_world)
|
36
|
+
#=> #<struct Trailblazer::Operation::Schema::Nodes::Attributes id=:save_the_world, ...>
|
37
|
+
#:id-introspect end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
module B
|
43
|
+
class Delete_DocsSequenceOptionsTest < Minitest::Spec
|
44
|
+
Memo = A::Id_DocSeqOptionsTest::Memo
|
45
|
+
|
46
|
+
it ":delete removes step" do
|
47
|
+
#:delete
|
48
|
+
module Memo::Operation
|
49
|
+
class Admin < Create
|
50
|
+
step nil, delete: :validate
|
51
|
+
end
|
52
|
+
end
|
53
|
+
#:delete end
|
54
|
+
|
55
|
+
=begin
|
56
|
+
output =
|
57
|
+
#:delete-inspect
|
58
|
+
Trailblazer::Developer.railway(Memo::Operation::Admin)
|
59
|
+
#=> [>save_the_world,>notify]
|
60
|
+
#:delete-inspect end
|
61
|
+
=end
|
62
|
+
|
63
|
+
#~ignore end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
module C
|
69
|
+
class Before_DocsSequenceOptionsTest < Minitest::Spec
|
70
|
+
it ":before" do
|
71
|
+
Memo = A::Id_DocSeqOptionsTest::Memo
|
72
|
+
|
73
|
+
#:before
|
74
|
+
module Memo::Operation
|
75
|
+
class Authorized < Memo::Operation::Create
|
76
|
+
step :policy, before: :validate
|
77
|
+
#~meths
|
78
|
+
include T.def_steps(:policy)
|
79
|
+
#~meths end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
#:before end
|
83
|
+
|
84
|
+
=begin
|
85
|
+
#:before-inspect
|
86
|
+
Trailblazer::Developer.railway(Memo::Operation::Authorized)
|
87
|
+
#=> [>policy,>validate,>save_the_world,>notify]
|
88
|
+
#:before-inspect end
|
89
|
+
=end
|
90
|
+
|
91
|
+
#~ignore end
|
92
|
+
end
|
93
|
+
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
module D
|
98
|
+
class After_DocsSequenceOptionsTest < Minitest::Spec
|
99
|
+
it ":after" do
|
100
|
+
Memo = Class.new(A::Id_DocSeqOptionsTest::Memo)
|
101
|
+
Memo::Operation = Module.new
|
102
|
+
Memo::Operation::Create = Class.new(A::Id_DocSeqOptionsTest::Memo::Operation::Create)
|
103
|
+
|
104
|
+
#:after
|
105
|
+
module Memo::Operation
|
106
|
+
class Authorized < Memo::Operation::Create
|
107
|
+
step :policy, after: :validate
|
108
|
+
#~meths
|
109
|
+
include T.def_steps(:policy)
|
110
|
+
#~meths end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
#:after end
|
114
|
+
|
115
|
+
=begin
|
116
|
+
#:after-inspect
|
117
|
+
Trailblazer::Developer.railway(Memo::Operation::Authorized)
|
118
|
+
#=> [>validate,>policy,>save_the_world,>notify]
|
119
|
+
#:after-inspect end
|
120
|
+
=end
|
121
|
+
|
122
|
+
#~ignore end
|
123
|
+
end
|
124
|
+
end
|
125
|
+
end
|
126
|
+
|
127
|
+
module E
|
128
|
+
class Replace_DocsSequenceOptionsTest < Minitest::Spec
|
129
|
+
Memo = Class.new
|
130
|
+
module Memo::Operation
|
131
|
+
class Create < Trailblazer::Operation
|
132
|
+
step :validate
|
133
|
+
step :save
|
134
|
+
step :notify
|
135
|
+
#~meths
|
136
|
+
include T.def_steps(:validate, :save, :notify)
|
137
|
+
#~meths end
|
138
|
+
end
|
139
|
+
end
|
140
|
+
|
141
|
+
it "{:replace} automatically assigns ID" do
|
142
|
+
#:replace
|
143
|
+
module Memo::Operation
|
144
|
+
class Update < Create
|
145
|
+
step :update, replace: :save
|
146
|
+
#~meths
|
147
|
+
include T.def_steps(:update)
|
148
|
+
#~meths end
|
149
|
+
end
|
150
|
+
|
151
|
+
end
|
152
|
+
#:replace end
|
153
|
+
|
154
|
+
=begin
|
155
|
+
#:replace-inspect
|
156
|
+
Trailblazer::Developer.railway(Memo::Operation::Update)
|
157
|
+
#=> [>validate,>update,>notify]
|
158
|
+
#:replace-inspect end
|
159
|
+
=end
|
160
|
+
assert Trailblazer::Activity::Introspect.Nodes(Memo::Operation::Update, id: :update)
|
161
|
+
|
162
|
+
#~ignore end
|
163
|
+
end
|
164
|
+
end
|
165
|
+
end
|
166
|
+
|
167
|
+
#@ {#replace} with {:id}
|
168
|
+
module E_2
|
169
|
+
class Replace_With_ID_DocsSequenceOptionsTest < Minitest::Spec
|
170
|
+
Memo = Class.new
|
171
|
+
module Memo::Operation
|
172
|
+
class Create < Trailblazer::Operation
|
173
|
+
step :validate
|
174
|
+
step :save
|
175
|
+
step :notify
|
176
|
+
#~meths
|
177
|
+
include T.def_steps(:validate, :save, :notify)
|
178
|
+
#~meths end
|
179
|
+
end
|
180
|
+
end
|
181
|
+
|
182
|
+
it "{:replace} allows explicit ID" do
|
183
|
+
#:replace-id
|
184
|
+
module Memo::Operation
|
185
|
+
class Update < Create
|
186
|
+
step :update, replace: :save, id: :update_memo
|
187
|
+
#~meths
|
188
|
+
include T.def_steps(:update)
|
189
|
+
#~meths end
|
190
|
+
end
|
191
|
+
|
192
|
+
end
|
193
|
+
#:replace-id end
|
194
|
+
|
195
|
+
# assert_equal Trailblazer::Developer.railway(Memo::Operation::Update), %([>validate,>update_memo,>notify])
|
196
|
+
|
197
|
+
Trailblazer::Activity::Introspect.Nodes(Memo::Operation::Update, id: :update_memo)
|
198
|
+
|
199
|
+
#~ignore end
|
200
|
+
end
|
201
|
+
end
|
202
|
+
end
|