From 09579a49f7499ad76f4cda39326acb6117eb48db Mon Sep 17 00:00:00 2001 From: Nick Sutterer Date: Mon, 18 Mar 2024 18:26:15 +0100 Subject: [PATCH] noyce!!! advance can also handle failures in the state machine. --- test/advance_test.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/test/advance_test.rb b/test/advance_test.rb index 7a9f024..d92553b 100644 --- a/test/advance_test.rb +++ b/test/advance_test.rb @@ -150,11 +150,17 @@ def render(text) Trailblazer::Endpoint::Runtime.({params: {id: 1}, seq: []}, adapter: action_adapter_with_model, default_matcher: default_matcher, matcher_context: self, flow_options: flow_options, &matcher_block) assert_equal @render, %([:ui_update, :update]) -# Update doesn't find model +# Update: Protocol doesn't find model flow_options = original_flow_options.merge(event_label: "☝ ⏵︎Update",) Trailblazer::Endpoint::Runtime.({params: {}, seq: []}, adapter: action_adapter_with_model, default_matcher: default_matcher, matcher_context: self, flow_options: flow_options, &matcher_block) assert_equal @render, %(404 not found: ) +# Update is invalid + flow_options = original_flow_options.merge(event_label: "☝ ⏵︎Update",) + Trailblazer::Endpoint::Runtime.({params: {id: 1}, seq: [], update: false}, adapter: action_adapter_with_model, default_matcher: default_matcher, matcher_context: self, flow_options: flow_options, &matcher_block) + assert_equal @render, %(failed: #) + + # {flow_options} is passed correctly through the entire run. flow_options = original_flow_options.merge(event_label: "☝ ⏵︎Update",) signal, (ctx, flow_options) = Trailblazer::Endpoint::Runtime.({params: {id: 1}, seq: []}, adapter: action_adapter_with_model, default_matcher: default_matcher, matcher_context: self, flow_options: flow_options, &matcher_block)