From 36b7ff2f63a95de0c9bbd75c1ae6e151a7b2b3da Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Tue, 7 Oct 2014 14:04:41 -0300 Subject: [PATCH] Fix partial for class method --- app/helpers/application_helper.rb | 2 +- test/unit/application_helper_test.rb | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 24dea59..04fdaeb 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -304,7 +304,7 @@ module ApplicationHelper def partial_for_class(klass, prefix=nil, suffix=nil) raise ArgumentError, 'No partial for object. Is there a partial for any class in the inheritance hierarchy?' if klass.nil? name = klass.name.underscore - controller.view_paths.reverse_each do |view_path| + controller.view_paths.each do |view_path| partial = partial_for_class_in_view_path(klass, view_path, prefix, suffix) return partial if partial end diff --git a/test/unit/application_helper_test.rb b/test/unit/application_helper_test.rb index f244b15..84c70b1 100644 --- a/test/unit/application_helper_test.rb +++ b/test/unit/application_helper_test.rb @@ -49,6 +49,20 @@ class ApplicationHelperTest < ActionView::TestCase end end + should 'plugins path take precedence over core path' do + core_path = 'core/' + plugin_path = 'path/' + @controller = mock() + @controller.stubs(:view_paths).returns([plugin_path, core_path]) + self.stubs(:params).returns({:controller => 'test'}) + + File.stubs(:exists?).returns(false) + File.stubs(:exists?).with(core_path+"test/_block.html.erb").returns(true) + File.stubs(:exists?).with(plugin_path+"test/_raw_html_block.html.erb").returns(true) + + assert_equal 'raw_html_block', partial_for_class(RawHTMLBlock) + end + should 'generate link to stylesheet' do File.stubs(:exists?).returns(false) File.expects(:exists?).with(Rails.root.join('public', 'stylesheets', 'something.css')).returns(true) -- libgit2 0.21.2