Commit 36b7ff2f63a95de0c9bbd75c1ae6e151a7b2b3da

Authored by Victor Costa
1 parent f323c51d

Fix partial for class method

app/helpers/application_helper.rb
... ... @@ -304,7 +304,7 @@ module ApplicationHelper
304 304 def partial_for_class(klass, prefix=nil, suffix=nil)
305 305 raise ArgumentError, 'No partial for object. Is there a partial for any class in the inheritance hierarchy?' if klass.nil?
306 306 name = klass.name.underscore
307   - controller.view_paths.reverse_each do |view_path|
  307 + controller.view_paths.each do |view_path|
308 308 partial = partial_for_class_in_view_path(klass, view_path, prefix, suffix)
309 309 return partial if partial
310 310 end
... ...
test/unit/application_helper_test.rb
... ... @@ -49,6 +49,20 @@ class ApplicationHelperTest < ActionView::TestCase
49 49 end
50 50 end
51 51  
  52 + should 'plugins path take precedence over core path' do
  53 + core_path = 'core/'
  54 + plugin_path = 'path/'
  55 + @controller = mock()
  56 + @controller.stubs(:view_paths).returns([plugin_path, core_path])
  57 + self.stubs(:params).returns({:controller => 'test'})
  58 +
  59 + File.stubs(:exists?).returns(false)
  60 + File.stubs(:exists?).with(core_path+"test/_block.html.erb").returns(true)
  61 + File.stubs(:exists?).with(plugin_path+"test/_raw_html_block.html.erb").returns(true)
  62 +
  63 + assert_equal 'raw_html_block', partial_for_class(RawHTMLBlock)
  64 + end
  65 +
52 66 should 'generate link to stylesheet' do
53 67 File.stubs(:exists?).returns(false)
54 68 File.expects(:exists?).with(Rails.root.join('public', 'stylesheets', 'something.css')).returns(true)
... ...