aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack
diff options
context:
space:
mode:
authorAlexey Vakhov <vakhov@gmail.com>2012-04-11 11:55:51 +0600
committerAlexey Vakhov <vakhov@gmail.com>2012-05-04 23:31:05 +0400
commit4bd05a7bdc5003c9ebb090dcb0dc4949e4fb8ad3 (patch)
tree31f9341dc568052b867f2033a3d9e30d3538b2ec /actionpack
parentdf36c5f7ffd2657e11eea4e407401c9ff2aa0533 (diff)
downloadrails-4bd05a7bdc5003c9ebb090dcb0dc4949e4fb8ad3.tar.gz
rails-4bd05a7bdc5003c9ebb090dcb0dc4949e4fb8ad3.tar.bz2
rails-4bd05a7bdc5003c9ebb090dcb0dc4949e4fb8ad3.zip
Fix assert_template :layout => nil assertion
Diffstat (limited to 'actionpack')
-rw-r--r--actionpack/lib/action_controller/test_case.rb7
-rw-r--r--actionpack/test/controller/action_pack_assertions_test.rb12
2 files changed, 17 insertions, 2 deletions
diff --git a/actionpack/lib/action_controller/test_case.rb b/actionpack/lib/action_controller/test_case.rb
index aee54bf515..f664da4ffe 100644
--- a/actionpack/lib/action_controller/test_case.rb
+++ b/actionpack/lib/action_controller/test_case.rb
@@ -20,7 +20,9 @@ module ActionController
ActiveSupport::Notifications.subscribe("render_template.action_view") do |name, start, finish, id, payload|
path = payload[:layout]
- @layouts[path] += 1
+ if path
+ @layouts[path] += 1
+ end
end
ActiveSupport::Notifications.subscribe("!render_template.action_view") do |name, start, finish, id, payload|
@@ -90,7 +92,8 @@ module ActionController
end
end
when Hash
- if expected_layout = options[:layout]
+ if options.key?(:layout)
+ expected_layout = options[:layout]
msg = message || sprintf("expecting layout <%s> but action rendered <%s>",
expected_layout, @layouts.keys)
diff --git a/actionpack/test/controller/action_pack_assertions_test.rb b/actionpack/test/controller/action_pack_assertions_test.rb
index 01151b336b..bc6630a02d 100644
--- a/actionpack/test/controller/action_pack_assertions_test.rb
+++ b/actionpack/test/controller/action_pack_assertions_test.rb
@@ -478,6 +478,13 @@ class AssertTemplateTest < ActionController::TestCase
end
end
+ def test_fails_expecting_no_layout
+ get :render_with_layout
+ assert_raise(ActiveSupport::TestCase::Assertion) do
+ assert_template :layout => nil
+ end
+ end
+
def test_passes_with_correct_layout
get :render_with_layout
assert_template :layout => "layouts/standard"
@@ -488,6 +495,11 @@ class AssertTemplateTest < ActionController::TestCase
assert_template :layout => "layouts/standard"
end
+ def test_passed_with_no_layout
+ get :hello_world
+ assert_template :layout => nil
+ end
+
def test_assert_template_reset_between_requests
get :hello_world
assert_template 'test/hello_world'