diff options
author | Justin Coyne <justin@curationexperts.com> | 2013-02-27 09:44:25 -0600 |
---|---|---|
committer | Justin Coyne <justin@curationexperts.com> | 2013-03-01 07:22:38 -0600 |
commit | 73deb3af23765882f67869afb4eaa8ad74a351d1 (patch) | |
tree | 846c47334e3ba2e9aabb6bc9c396841b4ed65776 /actionpack/test/controller | |
parent | b49a2a779ba6deba108d1f842ab5b7bc7460aa14 (diff) | |
download | rails-73deb3af23765882f67869afb4eaa8ad74a351d1.tar.gz rails-73deb3af23765882f67869afb4eaa8ad74a351d1.tar.bz2 rails-73deb3af23765882f67869afb4eaa8ad74a351d1.zip |
Allow use of assert_template with the :file option.
This worked in Rails 3.2, but was a regression in 4.0.0.beta1
Diffstat (limited to 'actionpack/test/controller')
-rw-r--r-- | actionpack/test/controller/action_pack_assertions_test.rb | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb index 5d727b3811..ba4efdd7ee 100644 --- a/actionpack/test/controller/action_pack_assertions_test.rb +++ b/actionpack/test/controller/action_pack_assertions_test.rb @@ -96,6 +96,14 @@ class ActionPackAssertionsController < ActionController::Base raise "post" if request.post? render :text => "request method: #{request.env['REQUEST_METHOD']}" end + + def render_file_absolute_path + render :file => File.expand_path('../../../README.rdoc', __FILE__) + end + + def render_file_relative_path + render :file => 'README.rdoc' + end end # Used to test that assert_response includes the exception message @@ -142,6 +150,16 @@ class ActionPackAssertionsControllerTest < ActionController::TestCase assert_tag :content => "/action_pack_assertions/flash_me" end + def test_render_file_absolute_path + get :render_file_absolute_path + assert_match /\A= Action Pack/, @response.body + end + + def test_render_file_relative_path + get :render_file_relative_path + assert_match /\A= Action Pack/, @response.body + end + def test_get_request assert_raise(RuntimeError) { get :raise_exception_on_get } get :raise_exception_on_post @@ -441,6 +459,23 @@ class AssertTemplateTest < ActionController::TestCase assert_template :partial => '_partial' end + def test_file_with_absolute_path_success + get :render_file_absolute_path + assert_template :file => File.expand_path('../../../README.rdoc', __FILE__) + end + + def test_file_with_relative_path_success + get :render_file_relative_path + assert_template :file => 'README.rdoc' + end + + def test_with_file_failure + get :render_file_absolute_path + assert_raise(ActiveSupport::TestCase::Assertion) do + assert_template :file => 'test/hello_world' + end + end + def test_with_nil_passes_when_no_template_rendered get :nothing assert_template nil |