From cce94e7232fdd53d5212d85b6f6ecc411baa0b16 Mon Sep 17 00:00:00 2001 From: Yves Senn Date: Sat, 15 Dec 2012 20:21:40 +0100 Subject: partials inside directory work with `assert_template` previously when a partial was placed inside a directory (eg. '/dir/_partial'), `assert_template` did not replace the '_' prefix when looking through rendered tempaltes, which resulted in an error. I modified it to replace both, the leading '_' and the last '_' after a '/'. --- .../fixtures/test/_directory/_partial_with_locales.html.erb | 1 + .../fixtures/test/render_partial_inside_directory.html.erb | 1 + actionpack/test/template/test_case_test.rb | 12 ++++++++++++ 3 files changed, 14 insertions(+) create mode 100644 actionpack/test/fixtures/test/_directory/_partial_with_locales.html.erb create mode 100644 actionpack/test/fixtures/test/render_partial_inside_directory.html.erb (limited to 'actionpack/test') diff --git a/actionpack/test/fixtures/test/_directory/_partial_with_locales.html.erb b/actionpack/test/fixtures/test/_directory/_partial_with_locales.html.erb new file mode 100644 index 0000000000..1cc8d41475 --- /dev/null +++ b/actionpack/test/fixtures/test/_directory/_partial_with_locales.html.erb @@ -0,0 +1 @@ +Hello <%= name %> diff --git a/actionpack/test/fixtures/test/render_partial_inside_directory.html.erb b/actionpack/test/fixtures/test/render_partial_inside_directory.html.erb new file mode 100644 index 0000000000..1461b95186 --- /dev/null +++ b/actionpack/test/fixtures/test/render_partial_inside_directory.html.erb @@ -0,0 +1 @@ +<%= render partial: 'test/_directory/partial_with_locales', locals: {'name' => 'Jane'} %> diff --git a/actionpack/test/template/test_case_test.rb b/actionpack/test/template/test_case_test.rb index c8441b6894..acd002ce73 100644 --- a/actionpack/test/template/test_case_test.rb +++ b/actionpack/test/template/test_case_test.rb @@ -338,6 +338,18 @@ module ActionView assert_match "i_was_never_rendered to be rendered but it was not.", e.message assert_match 'Expected ["/test/partial"] to include "i_was_never_rendered"', e.message end + + test 'specifying locals works when the partial is inside a directory with underline prefix' do + controller.controller_path = "test" + render(template: 'test/render_partial_inside_directory') + assert_template partial: 'test/_directory/_partial_with_locales', locals: { 'name' => 'Jane' } + end + + test 'specifying locals works when the partial is inside a directory without underline prefix' do + controller.controller_path = "test" + render(template: 'test/render_partial_inside_directory') + assert_template partial: 'test/_directory/partial_with_locales', locals: { 'name' => 'Jane' } + end end module AHelperWithInitialize -- cgit v1.2.3