aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/response_body_is_proc_test.rb
blob: fd94832624db3fa352b151548786d280ad990f38 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
require 'abstract_unit'

class ResponseBodyIsProcTest < ActionDispatch::IntegrationTest
  class TestController < ActionController::Base
    def test
      self.response_body = proc { |response, output|
        output.write 'Hello'
      }
    end
  end

  def test_simple_get
    with_test_route_set do
      assert_deprecated do
        get '/test'
      end
      assert_response :success
      assert_equal 'Hello', response.body
    end
  end

  private

    def with_test_route_set(options = {})
      with_routing do |set|
        set.draw do
          match ':action', :to => ::ResponseBodyIsProcTest::TestController
        end

        @app = self.class.build_app(set) do |middleware|
          middleware.delete "ActionDispatch::ShowExceptions"
        end

        yield
      end
    end
end