Skip to content

Commit

Permalink
noyce!!! advance can also handle failures in the state machine.
Browse files Browse the repository at this point in the history
  • Loading branch information
apotonick committed Mar 18, 2024
1 parent e3fa1e3 commit 09579a4
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion test/advance_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: #<struct AdvanceTest::Posting id=1>)


# {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)
Expand Down

0 comments on commit 09579a4

Please sign in to comment.