From bd7181e4a0edf18dac886d31622ba18d1ca93eaf Mon Sep 17 00:00:00 2001 From: Yogesh Khater Date: Tue, 14 Jan 2020 12:40:27 +0530 Subject: [PATCH] Assign `:id` as method name if task is method object --- lib/trailblazer/activity/dsl/linear/normalizer.rb | 2 +- test/activity_test.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/trailblazer/activity/dsl/linear/normalizer.rb b/lib/trailblazer/activity/dsl/linear/normalizer.rb index ec7dce54..0c32feef 100644 --- a/lib/trailblazer/activity/dsl/linear/normalizer.rb +++ b/lib/trailblazer/activity/dsl/linear/normalizer.rb @@ -77,7 +77,7 @@ def wrap_task_with_step_interface((ctx, flow_options), **) end def normalize_id((ctx, flow_options), **) - id = ctx[:id] || ctx[:task] + id = ctx[:id] || ( ctx[:task].respond_to?(:name) ? ctx[:task].name : ctx[:task] ) return Trailblazer::Activity::Right, [ctx.merge(id: id), flow_options] end diff --git a/test/activity_test.rb b/test/activity_test.rb index 6a69870b..8fe66a8d 100644 --- a/test/activity_test.rb +++ b/test/activity_test.rb @@ -56,7 +56,7 @@ class ActivityTest < Minitest::Spec end end - exception.message.sub(/0x\w+/, "0x").must_equal %{ID #.f> is already taken. Please specify an `:id`.} + exception.message.sub(/0x\w+/, "0x").must_equal %{ID f is already taken. Please specify an `:id`.} end it "accepts {:outputs}" do @@ -614,7 +614,7 @@ def add_1(wrap_ctx, original_args) step implementing.method(:b) end - activity.to_h[:nodes].collect(&:id).must_equal ["Start.default", :a, implementing.method(:b), "End.success"] + activity.to_h[:nodes].collect(&:id).must_equal ["Start.default", :a, :b, "End.success"] end describe "#merge!" do