aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch/response_body_is_proc_test.rb
blob: 86d788b8459901c343bc2f43ae5f70f1ef7180df (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
38
require 'abstract_unit'

class ResponseBodyIsProcTest < ActionDispatch::IntegrationTest
  class TestController < ActionController::Base
    def test
      request.session_options[:renew] = true
      self.response_body = proc { |response, output|
        puts caller
        output.write 'Hello'
      }
    end

    def rescue_action(e) raise end
  end

  def test_simple_get
    with_test_route_set do
      get '/test'
      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