Commit d6e22eff2bc833af0224342e510e457d66111f73

Authored by Victor Costa
1 parent 9883b50d

rails3: fix public_path from plugins

Not sure if compute_public_path should be replaced by a simple File.join.
Consider the use of asset_path if the current solution isn't safe.
lib/noosfero/plugin.rb
... ... @@ -107,7 +107,7 @@ class Noosfero::Plugin
107 107 end
108 108  
109 109 def public_path(file = '')
110   - compute_public_path((public_name + '/' + file), 'plugins')
  110 + File.join('/plugins', public_name, file)
111 111 end
112 112  
113 113 def root_path
... ...
test/functional/application_controller_test.rb
... ... @@ -360,6 +360,9 @@ class ApplicationControllerTest < ActionController::TestCase
360 360 environment.enable_plugin(Plugin1.name)
361 361 environment.enable_plugin(Plugin2.name)
362 362  
  363 + ActionView::Helpers::AssetTagHelper::StylesheetIncludeTag.any_instance.stubs('asset_file_path!')
  364 + ActionView::Helpers::AssetTagHelper::JavascriptIncludeTag.any_instance.stubs('asset_file_path!')
  365 +
363 366 get :index
364 367  
365 368 assert_tag :tag => 'link', :attributes => {:href => /#{plugin1_path}/, :type => 'text/css', :rel => 'stylesheet'}
... ... @@ -391,6 +394,8 @@ class ApplicationControllerTest < ActionController::TestCase
391 394 environment.enable_plugin(Plugin1.name)
392 395 environment.enable_plugin(Plugin2.name)
393 396  
  397 + ActionView::Helpers::AssetTagHelper::JavascriptIncludeTag.any_instance.stubs('asset_file_path!')
  398 +
394 399 get :index
395 400  
396 401 assert_tag :tag => 'script', :attributes => {:src => /#{plugin1_path}/, :type => 'text/javascript'}
... ...