test/docs/model_test.rb in trailblazer-macro-2.1.1 vs test/docs/model_test.rb in trailblazer-macro-2.1.2

- old
+ new

@@ -43,10 +43,17 @@ step Model( Song, :find_by, :title ) # .. end #:update-with-find-by-key end + #:update-with-not-found-end + class UpdateFailureWithModelNotFound < Trailblazer::Operation + step Model( Song, :find_by, not_found_end: true ) + # .. + end + #:update-with-not-found-end end + it do #:update-ok result = Update.(params: { id: 1 }) result[:model] #=> #<struct Song id=1, title="nil"> #:update-ok end @@ -79,9 +86,22 @@ result[:model] #=> nil result.success? #=> false #:update-with-find-by-key-fail end result[:model].must_be_nil result.success?.must_equal false + end + + it do + #:update-with-not-found-end-use + result = UpdateFailureWithModelNotFound.(params: {title: nil}) + result[:model] #=> nil + result.success? #=> false + result.event #=> #<Trailblazer::Activity::End semantic=:not_found> + #:update-with-not-found-end-use end + + result[:model].must_be_nil + result.success?.must_equal false + result.event.inspect.must_equal %{#<Trailblazer::Activity::End semantic=:not_found>} end #:show class Show < Trailblazer::Operation step Model( Song, :[] )