From ac960d5efd7dff7bf04c7da682603ab60b834527 Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Wed, 15 Nov 2023 12:57:03 +0100 Subject: [PATCH] fix a bug in `patch` where `Subprocess()` was missing in `Macro::Strategy`. --- lib/trailblazer/macro/strategy.rb | 2 +- test/docs/wrap_test.rb | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/lib/trailblazer/macro/strategy.rb b/lib/trailblazer/macro/strategy.rb index c40a84c..c7dcd1a 100644 --- a/lib/trailblazer/macro/strategy.rb +++ b/lib/trailblazer/macro/strategy.rb @@ -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}. diff --git a/test/docs/wrap_test.rb b/test/docs/wrap_test.rb index cf2d5ec..5dd01e7 100644 --- a/test/docs/wrap_test.rb +++ b/test/docs/wrap_test.rb @@ -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