diff --git a/gems/actionpack/7.2/_test/test.rb b/gems/actionpack/7.2/_test/test.rb index 377cc99f..88020fed 100644 --- a/gems/actionpack/7.2/_test/test.rb +++ b/gems/actionpack/7.2/_test/test.rb @@ -82,3 +82,12 @@ def matches?(request) mount Rack::Head.new(->(_env) { [200, { "content-type" => "text/plain" }, ["OK"]] }), at: "/head", as: :head with_default_scope(module: "v1") { get "ping", to: "ping#show" }.has_named_route?(:ping) end + +# render_to_body returns what the including class renders, so it can be truthy +class BodyRenderer + include AbstractController::Rendering + + def show + render_to_body(template: "show") ? "rendered" : "empty" + end +end diff --git a/gems/actionpack/7.2/_test/test.rbs b/gems/actionpack/7.2/_test/test.rbs index b1a08e95..d704bb01 100644 --- a/gems/actionpack/7.2/_test/test.rbs +++ b/gems/actionpack/7.2/_test/test.rbs @@ -14,3 +14,9 @@ end class AdminConstraint def matches?: (ActionDispatch::Request request) -> bool end + +class BodyRenderer + include AbstractController::Rendering + + def show: () -> String +end diff --git a/gems/actionpack/7.2/actioncontroller.rbs b/gems/actionpack/7.2/actioncontroller.rbs index 3a515900..fcf46584 100644 --- a/gems/actionpack/7.2/actioncontroller.rbs +++ b/gems/actionpack/7.2/actioncontroller.rbs @@ -291,6 +291,9 @@ end module AbstractController module Rendering + # Performs the actual template rendering. + def render_to_body: (?::Hash[untyped, untyped] options) -> untyped + def render_to_string: (*untyped args) ?{ () -> untyped } -> ::String end end diff --git a/gems/actionpack/7.2/actionpack-generated.rbs b/gems/actionpack/7.2/actionpack-generated.rbs index 7bb05ee0..0eec1a32 100644 --- a/gems/actionpack/7.2/actionpack-generated.rbs +++ b/gems/actionpack/7.2/actionpack-generated.rbs @@ -511,9 +511,6 @@ module AbstractController # sticks the result in self.response_body. def render: (*untyped args) { () -> untyped } -> untyped - # Performs the actual template rendering. - def render_to_body: (?::Hash[untyped, untyped] options) -> nil - # Returns Content-Type of rendered content. def rendered_format: () -> untyped diff --git a/gems/actionpack/8.1/_test/test.rb b/gems/actionpack/8.1/_test/test.rb index eb1b683c..e21c064d 100644 --- a/gems/actionpack/8.1/_test/test.rb +++ b/gems/actionpack/8.1/_test/test.rb @@ -168,3 +168,12 @@ def matches?(request) mount Rack::Head.new(->(_env) { [200, { "content-type" => "text/plain" }, ["OK"]] }), at: "/head", as: :head with_default_scope(module: "v1") { get "ping", to: "ping#show" }.has_named_route?(:ping) end + +# render_to_body returns what the including class renders, so it can be truthy +class BodyRenderer + include AbstractController::Rendering + + def show + render_to_body(template: "show") ? "rendered" : "empty" + end +end diff --git a/gems/actionpack/8.1/_test/test.rbs b/gems/actionpack/8.1/_test/test.rbs index 1b4162bb..6cf28590 100644 --- a/gems/actionpack/8.1/_test/test.rbs +++ b/gems/actionpack/8.1/_test/test.rbs @@ -28,3 +28,9 @@ end class AdminConstraint def matches?: (ActionDispatch::Request request) -> bool end + +class BodyRenderer + include AbstractController::Rendering + + def show: () -> String +end diff --git a/gems/actionpack/8.1/actioncontroller.rbs b/gems/actionpack/8.1/actioncontroller.rbs index bd99d005..379d6247 100644 --- a/gems/actionpack/8.1/actioncontroller.rbs +++ b/gems/actionpack/8.1/actioncontroller.rbs @@ -317,6 +317,9 @@ end module AbstractController module Rendering + # Performs the actual template rendering. + def render_to_body: (?::Hash[untyped, untyped] options) -> untyped + def render_to_string: (*untyped args) ?{ () -> untyped } -> ::String end end diff --git a/gems/actionpack/8.1/actionpack-generated.rbs b/gems/actionpack/8.1/actionpack-generated.rbs index b4434d68..ea50abf6 100644 --- a/gems/actionpack/8.1/actionpack-generated.rbs +++ b/gems/actionpack/8.1/actionpack-generated.rbs @@ -527,9 +527,6 @@ module AbstractController # Supported options depend on the underlying `render_to_body` implementation. def render: (*untyped args) ?{ (?) -> untyped } -> untyped - # Performs the actual template rendering. - def render_to_body: (?::Hash[untyped, untyped] options) -> nil - # Returns `Content-Type` of rendered content. def rendered_format: () -> untyped