Skip to content

Commit

Permalink
Assign :id as method name if task is method object
Browse files Browse the repository at this point in the history
  • Loading branch information
Yogesh Khater committed Jan 14, 2020
1 parent 66b7000 commit bd7181e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/trailblazer/activity/dsl/linear/normalizer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions test/activity_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ class ActivityTest < Minitest::Spec
end
end

exception.message.sub(/0x\w+/, "0x").must_equal %{ID #<Method: #<Module:0x>.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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit bd7181e

Please sign in to comment.