Skip to content

Commit

Permalink
feat: remove deprecated tracing syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
seuros committed Jun 13, 2024
1 parent dea8899 commit b9e9145
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 1 addition & 5 deletions lib/trailblazer/rails/controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module Controller
# TODO: deprecate {*dependencies}.
def run_v21(operation, *dependencies, **variables, &block)
result = if Rails.application.config.trailblazer.enable_tracing
_run_operation_v21(operation, :trace, *dependencies, **variables).tap { |r| _operation_trace(r) }
_run_operation_v21(operation, :wtf?, *dependencies, **variables)
else
_run_operation_v21(operation, :call, *dependencies, **variables)
end
Expand Down Expand Up @@ -53,10 +53,6 @@ def _run_operation_v21(operation, call_method, *dependencies, **variables)
)
end

def _operation_trace(result)
puts result.wtf?
end

def _assign_trb_ivars(result)
@model = result[:model]
@form = _wrap_with_trb_form(result["contract.default"], @model.class)
Expand Down
16 changes: 16 additions & 0 deletions test/integration/songs_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,22 @@
require 'minitest/capybara'

class SongsControllerTest < Minitest::Capybara::Spec
it 'can trace' do
# Capture the standard output
stdout = StringIO.new
original_stdout = $stdout
$stdout = stdout
Rails.application.config.trailblazer.enable_tracing = true
visit "/songs/new"
# Assert that the output contains the expected string
assert_equal "Song::Operation::New\n|-- \e[32mStart.default\e[0m\n|-- \e[32mmodel.build\e[0m\n|-- \e[32mcontract.build\e[0m\n`-- End.success\n",
stdout.string

ensure
$stdout = original_stdout
Rails.application.config.trailblazer.enable_tracing = false
end

it "new" do
visit "/songs/new"
assert page.has_css? "form.new_song[action='/songs']"
Expand Down

0 comments on commit b9e9145

Please sign in to comment.