Skip to content
This repository
Browse code

New test: setting response_body to a Proc should be supported.

  • Loading branch information...
commit 2ab42dcc3ed0d37e64da10063b4162bd8e8cb4bf 1 parent 030e1d0
authored
38  actionpack/test/dispatch/response_body_is_proc_test.rb
... ...
@@ -0,0 +1,38 @@
  1
+require 'abstract_unit'
  2
+
  3
+class ResponseBodyIsProcTest < ActionDispatch::IntegrationTest
  4
+  class TestController < ActionController::Base
  5
+    def test
  6
+      request.session_options[:renew] = true
  7
+      self.response_body = proc { |response, output|
  8
+        puts caller
  9
+        output.write 'Hello'
  10
+      }
  11
+    end
  12
+
  13
+    def rescue_action(e) raise end
  14
+  end
  15
+
  16
+  def test_simple_get
  17
+    with_test_route_set do
  18
+      get '/test'
  19
+      assert_response :success
  20
+      assert_equal 'Hello', response.body
  21
+    end
  22
+  end
  23
+
  24
+  private
  25
+    def with_test_route_set(options = {})
  26
+      with_routing do |set|
  27
+        set.draw do
  28
+          match ':action', :to => ::ResponseBodyIsProcTest::TestController
  29
+        end
  30
+
  31
+        @app = self.class.build_app(set) do |middleware|
  32
+          middleware.delete "ActionDispatch::ShowExceptions"
  33
+        end
  34
+
  35
+        yield
  36
+      end
  37
+    end
  38
+end

0 notes on commit 2ab42dc

Please sign in to comment.
Something went wrong with that request. Please try again.