test/docs/model_test.rb in trailblazer-macro-2.1.6 vs test/docs/model_test.rb in trailblazer-macro-2.1.7

- old
+ new

@@ -14,11 +14,11 @@ end end #:op class Create < Trailblazer::Operation - step Model( Song, :new ) + step Model(Song, :new) # .. end #:op end it do @@ -118,7 +118,21 @@ result[:model] #=> #<struct Song id=1, title="Roxanne"> #:show-ok end result.success?.must_equal true result[:model].inspect.must_equal %{#<struct DocsModelTest::Song id=100, title=nil>} + end + + it "allows injecting {:model.class} and friends" do + class Hit < Song + end + + result = Create.(params: {}, :"model.class" => Hit) + + result[:model].inspect.must_equal %{#<struct DocsModelTest::Hit id=nil, title=nil>} + + # inject all variables + result = Create.(params: {title: "Olympia"}, "model.class": Hit, "model.action": :find_by, "model.find_by_key": :title) + + result[:model].inspect.must_equal %{#<struct DocsModelTest::Hit id=2, title="Olympia">} end end