Skip to content

Commit

Permalink
fix a bug in patch where Subprocess() was missing in `Macro::Stra…
Browse files Browse the repository at this point in the history
…tegy`.
  • Loading branch information
apotonick committed Nov 15, 2023
1 parent fef3161 commit ac960d5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/trailblazer/macro/strategy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Macro
class Strategy # We want to look like a real {Linear::Strategy}.
class << self
extend Forwardable
def_delegators :block_activity, :step, :pass, :fail # TODO: add all DSL::Helper
def_delegators :block_activity, :step, :pass, :fail, :Subprocess # TODO: add all DSL::Helper
end

# This makes {Wrap} look like {block_activity}.
Expand Down
13 changes: 13 additions & 0 deletions test/docs/wrap_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -661,6 +661,19 @@ class MyValidation < Trailblazer::Activity::Railway

#@ the patched version only runs {mock_validation}.
assert_invoke patched_activity, seq: %{[:mock_validation]}

# Patch Wrap/Subprocess/step, put step after {validate}
patched_activity = Trailblazer::Activity::DSL::Linear::Patch.call(
activity,
["Wrap/WrapUnitTest::HandleUnsafeProcess", :validation],
-> { step mock_validation }
)

#@ the original activity with Wrap is unchanged.
assert_invoke activity, seq: %{[:validate]}

#@ the patched version only runs {mock_validation}.
assert_invoke patched_activity, seq: %{[:validate, :mock_validation]}
end
end

Expand Down

2 comments on commit ac960d5

@contentfree
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is that CI failure meaningful?

@apotonick
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the "random" ID of the Subprocess() step is identical to an existing one, maybe we should use longer random IDs. Sorry for the late reply ☕

Please sign in to comment.