Skip to content

Commit

Permalink
Merge pull request rails#40172 from p8/shorten-inspect-on-controller
Browse files Browse the repository at this point in the history
Shorten inspect on AbstractController::Base
  • Loading branch information
kaspth authored Sep 5, 2020
2 parents 0e5f9a0 + 080edb4 commit 46bdcbf
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions actionpack/lib/abstract_controller/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,10 @@ def self.supports_path?
true
end

def inspect # :nodoc:
"#<#{self.class.name}:#{'%#016x' % (object_id << 1)}>"
end

private
# Returns true if the name can be considered an action because
# it has a method defined in the controller.
Expand Down
4 changes: 4 additions & 0 deletions actionpack/test/controller/base_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,10 @@ def test_response_has_default_headers
ensure
ActionDispatch::Response.default_headers = original_default_headers
end

def test_inspect
assert_match(/\A#<EmptyController:0x[0-9a-f]+>\z/, @empty.inspect)
end
end

class PerformActionTest < ActionController::TestCase
Expand Down
5 changes: 5 additions & 0 deletions actionpack/test/controller/metal_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,9 @@ def test_response_does_not_have_default_headers
ensure
ActionDispatch::Response.default_headers = original_default_headers
end

def test_inspect
controller = SimpleController.new
assert_match(/\A#<MetalControllerInstanceTests::SimpleController:0x[0-9a-f]+>\z/, controller.inspect)
end
end

0 comments on commit 46bdcbf

Please sign in to comment.