Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: remove last deprecation warning #53

Open
wants to merge 1 commit into
base: model
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/trailblazer/macro/nested.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ def self.call_dynamic_nested_activity((ctx, flow_options), runner:, **circuit_op

def self.compute_legacy_return_signal(return_signal)
actual_semantic = return_signal.to_h[:semantic]
applied_signal = SUCCESS_SEMANTICS.include?(actual_semantic) ? Activity::Right : Activity::Left # TODO: we could also provide PassFast/FailFast.
_applied_signal = SUCCESS_SEMANTICS.include?(actual_semantic) ? Activity::Right : Activity::Left # TODO: we could also provide PassFast/FailFast.
end

# This is used in Nested and Each where some tasks don't have a corresponding, hard-wired
Expand Down
6 changes: 3 additions & 3 deletions test/docs/each_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -711,7 +711,7 @@ class Validate < Trailblazer::Activity::Railway
assert_equal Trailblazer::Developer::Introspect.find_path(activity, ["Each-1"])[0].id, "Each-1"
assert_equal Trailblazer::Developer::Introspect.find_path(activity, ["Each/composers_for_each"])[0].id, "Each/composers_for_each"

assert_match /Each\/\w+/, Trailblazer::Activity::Introspect::Nodes(activity).values[1].id # FIXME: this test sucks.
assert_match (/Each\/\w+/), Trailblazer::Activity::Introspect::Nodes(activity).values[1].id # FIXME: this test sucks.
end
end

Expand Down Expand Up @@ -740,7 +740,7 @@ def self.block

ctx = {seq: [], dataset: [3,2,1]}

stack, signal, (ctx, _) = Trailblazer::Developer::Trace.invoke(activity, [ctx, {}])
stack, _signal, (_ctx, _) = Trailblazer::Developer::Trace.invoke(activity, [ctx, {}])

output = Trailblazer::Developer::Trace::Present.(stack) do |trace_nodes:, **|
{node_options: {trace_nodes[0] => {label: "<a-Each-b>"}}}
Expand Down Expand Up @@ -790,7 +790,7 @@ def self.block
}

# signal, (_ctx, _) = Trailblazer::Activity::TaskWrap.invoke(activity, [ctx])
signal, (_ctx, _) = Trailblazer::Developer.wtf?(activity, [ctx], exec_context: my_exec_context)
_signal, (_ctx, _) = Trailblazer::Developer.wtf?(activity, [ctx], exec_context: my_exec_context)

assert_equal _ctx[:collected_from_each], ["1-0", "2-1", "3-2"]
end
Expand Down
2 changes: 1 addition & 1 deletion test/docs/guard_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def process(options, **)
#---
#- Guard inheritance
class New < Create
step Policy::Guard( ->(options, current_user:, **) { current_user } ), override: true
step Policy::Guard( ->(options, current_user:, **) { current_user } ), replace: :"policy.default.eval"
end

it { assert_equal Trailblazer::Developer.railway(New), %{[>policy.default.eval,>process]} }
Expand Down
32 changes: 16 additions & 16 deletions test/docs/model/find_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,22 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:find_by_id-invoke
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: "1"}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: "1"}, seq: [])
ctx[:model] #=> #<struct Song id=1>
#:find_by_id-invoke end

assert_equal ctx[:model].inspect, %{#<struct #{Song} id="1">}
end

it do
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {short_id: nil}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {short_id: nil}, seq: [])
assert_equal ctx[:model].inspect, %{nil}
end
#~ctx_to_result end

# TODO: put this test somewhere else
it "doesn't leak anything but {:model} to the outer world" do
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: "1"}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: "1"}, seq: [])

assert_equal ctx.keys.inspect, %([:params, :seq, :model])
end
Expand Down Expand Up @@ -75,15 +75,15 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:find_by_column-invoke
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {short_id: "1f396"}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {short_id: "1f396"}, seq: [])
ctx[:model] #=> #<struct Song short_id="1f396">
#:find_by_column-invoke end

assert_equal ctx[:model].inspect, %{#<struct #{Song} short_id="1f396">}
end

it do
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {short_id: nil}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {short_id: nil}, seq: [])
assert_equal ctx[:model].inspect, %{nil}
end
#~ctx_to_result end
Expand All @@ -108,15 +108,15 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:params_key-invoke
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {slug: "1f396"}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {slug: "1f396"}, seq: [])
ctx[:model] #=> #<struct Song id=2, id="1f396">
#:params_key-invoke end

assert_equal ctx[:model].inspect, %{#<struct #{Song} id="1f396">}
end

it do
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {slug: nil}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {slug: nil}, seq: [])
assert_equal ctx[:model].inspect, %{nil}
end
#~ctx_to_result end
Expand Down Expand Up @@ -146,15 +146,15 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:find_with-invoke
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: 2}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: 2}, seq: [])
ctx[:model] #=> #<struct Song id=2>
#:find_with-invoke end

assert_equal ctx[:model].inspect, %{#<struct #{Song} id=2>}
end

it do
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: nil}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: nil}, seq: [])
assert_equal ctx[:model].inspect, %{nil}
end
#~ctx_to_result end
Expand Down Expand Up @@ -186,7 +186,7 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:id_from-invoke
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {song: {id: "1f396"}}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {song: {id: "1f396"}}, seq: [])
ctx[:model] #=> #<struct Song id="1f396">
#:id_from-invoke end

Expand All @@ -195,7 +195,7 @@ class Update < Trailblazer::Activity::Railway
end

it do
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {}, seq: [])

assert_equal ctx[:model].inspect, %{nil}
assert_equal ctx[:seq].inspect, %([])
Expand Down Expand Up @@ -227,7 +227,7 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:find-ok
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, {params: {id: 1}, seq: []})
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, {params: {id: 1}, seq: []})
ctx[:model] #=> #<struct Song id=1, title="Roxanne">
#:find-ok end

Expand Down Expand Up @@ -259,7 +259,7 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:show-ok
signal, (ctx, _) = Trailblazer::Developer.wtf?(Song::Activity::Update, [{params: {id: 1}, seq: []}])
_signal, (ctx, _) = Trailblazer::Developer.wtf?(Song::Activity::Update, [{params: {id: 1}, seq: []}])
ctx[:model] #=> #<struct Song id=1, title="Roxanne">
#:show-ok end

Expand Down Expand Up @@ -326,7 +326,7 @@ class Create < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:new-invoke
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, seq: [])
ctx[:model] #=> #<struct Song id=1>
#:new-invoke end

Expand Down Expand Up @@ -356,7 +356,7 @@ class Create < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:build-invoke
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, seq: [])
ctx[:model] #=> #<struct Song id=1>
#:build-invoke end

Expand Down Expand Up @@ -389,7 +389,7 @@ class Update < Trailblazer::Activity::Railway
assert_invoke Song::Activity::Update, params: {id: nil}, terminus: :not_found

#:not-found-invoke
signal, (ctx, _) = Trailblazer::Activity::TaskWrap.invoke(Song::Activity::Update, [{params: {id: nil}},{}])
signal, (_ctx, _) = Trailblazer::Activity::TaskWrap.invoke(Song::Activity::Update, [{params: {id: nil}},{}])
puts signal #=> #<Trailblazer::Activity::End semantic=:not_found>
#:not-found-invoke end
end
Expand Down
22 changes: 11 additions & 11 deletions test/docs/model_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:create
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, seq: [])
puts ctx[:model] #=> #<struct Song id=nil, title=nil>
#:create end

Expand Down Expand Up @@ -102,7 +102,7 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:update-with-find-by-key-ok
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {title: "Test"}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {title: "Test"}, seq: [])
ctx[:model] #=> #<struct Song id=2, title="Test">
#:update-with-find-by-key-ok end

Expand All @@ -111,7 +111,7 @@ class Update < Trailblazer::Activity::Railway

it do
#:key-title-fail
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {title: nil}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {title: nil}, seq: [])

assert_equal ctx[:model].inspect, %{nil}
#:key-title-fail end
Expand All @@ -138,7 +138,7 @@ class Update < Trailblazer::Activity::Railway
#~ctx_to_result
it do
#:show-ok
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: 1}, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: 1}, seq: [])
ctx[:model] #=> #<struct Song id=1, title="Roxanne">
#:show-ok end

Expand Down Expand Up @@ -166,14 +166,14 @@ class Hit < Song
end

#:di-model-class
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, :"model.class" => Hit, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, :"model.class" => Hit, seq: [])
#:di-model-class end

assert_equal ctx[:model].inspect, %{#<struct #{Hit} id=nil, title=nil>}

# inject all variables
#:di-all
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create,
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create,
params: {title: "Olympia"}, # some random variable.
"model.class": Hit,
"model.action": :find_by,
Expand Down Expand Up @@ -203,7 +203,7 @@ class Create < Trailblazer::Activity::Railway
end

it do
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, :"model.class" => Hit, seq: [])
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, :"model.class" => Hit, seq: [])

assert_equal ctx[:model].inspect, %{#<struct #{Hit} id=nil, title=nil>}
end
Expand All @@ -224,7 +224,7 @@ class Create < Trailblazer::Operation
end
#:in end

signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, my_id: 1, :"model.class" => Hit)
_signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Create, params: {}, my_id: 1, :"model.class" => Hit)

assert_equal ctx[:model].inspect, %{#<struct #{Hit} id=1, title=nil>}
=begin
Expand All @@ -233,7 +233,7 @@ class Create < Trailblazer::Operation
#:in-call end
=end
end
end
end
end

class Model404TerminusTest < Minitest::Spec
Expand All @@ -257,7 +257,7 @@ class Update < Trailblazer::Activity::Railway
assert_invoke Song::Activity::Update, params: {id: nil}, terminus: :not_found

#:not_found
signal, (ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: nil})
signal, (_ctx, _) = Trailblazer::Activity.(Song::Activity::Update, params: {id: nil})
puts signal #=> #<Trailblazer::Activity::End semantic=:not_found>
#:not_found end
end
Expand Down Expand Up @@ -286,7 +286,7 @@ class Update < Trailblazer::Activity::Railway
assert_invoke Song::Activity::Update, params: {id: nil}, terminus: :not_found

#:not_found
signal, (ctx, _) = Trailblazer::Activity::TaskWrap.invoke(Song::Activity::Update, [{params: {id: nil}},{}])
signal, (_ctx, _) = Trailblazer::Activity::TaskWrap.invoke(Song::Activity::Update, [{params: {id: nil}},{}])
puts signal #=> #<Trailblazer::Activity::End semantic=:not_found>
#:not_found end
end
Expand Down
2 changes: 1 addition & 1 deletion test/docs/nested_static_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -699,7 +699,7 @@ class NestedStrategyComplianceTest < Minitest::Spec
]
)
#:create-introspect end
assert_match /user_proc=encode_id3>/, output
assert_match (/user_proc=encode_id3>/), output
end

# TODO: test more options.
Expand Down
2 changes: 1 addition & 1 deletion test/docs/pundit_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ class Edit < Trailblazer::Operation
end

class Update < Edit
step Policy::Pundit( MyPolicy, :new?, name: "first" ), override: true
step Policy::Pundit( MyPolicy, :new?, name: "first" ), replace: :"policy.first.eval"
end

it { assert_equal Trailblazer::Developer.railway(Edit), %{[>policy.first.eval,>policy.second.eval]} }
Expand Down
2 changes: 1 addition & 1 deletion test/docs/rescue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class NestedInsanity < Trailblazer::Operation
fail ->(options, **) { options["outer-err"] = true }, id: "nested/failure"
end

it { assert_match /\[>Rescue\/.{1,3},>nested/, Trailblazer::Developer.railway(NestedInsanity) } # FIXME: better introspect tests for all id-generating macros.
it { assert_match (/\[>Rescue\/.{1,3},>nested/), Trailblazer::Developer.railway(NestedInsanity) } # FIXME: better introspect tests for all id-generating macros.
it { assert_equal NestedInsanity.().inspect("a", "y", "z", "b", "c", "e", "inner-err", "outer-err"), %{<Result:true [true, true, true, true, true, true, nil, nil] >} }
it { assert_equal NestedInsanity.( "raise-y" => true).inspect("a", "y", "z", "b", "c", "e", "inner-err", "outer-err"), %{<Result:false [true, true, nil, nil, nil, nil, true, true] >} }
it { assert_equal NestedInsanity.( "raise-a" => true).inspect("a", "y", "z", "b", "c", "e", "inner-err", "outer-err"), %{<Result:false [true, true, true, true, nil, nil, nil, true] >} }
Expand Down
Loading