Commit 356ed1a35203e1fabc2e1762759c28090de75c15
1 parent
a4d28dc0
Exists in
master
and in
26 other branches
Fix inclusion of javascript files from plugins
Showing
2 changed files
with
14 additions
and
1 deletions
Show diff stats
app/helpers/layout_helper.rb
... | ... | @@ -28,7 +28,7 @@ module LayoutHelper |
28 | 28 | end |
29 | 29 | |
30 | 30 | def noosfero_javascript |
31 | - plugins_javascripts = @plugins.flat_map{ |plugin| plugin.js_files.map{ |js| plugin.class.public_path(js, true) } }.flatten | |
31 | + plugins_javascripts = @plugins.flat_map{ |plugin| Array.wrap(plugin.js_files).map{ |js| plugin.class.public_path(js, true) } }.flatten | |
32 | 32 | |
33 | 33 | output = '' |
34 | 34 | output += render 'layouts/javascript' | ... | ... |
test/unit/layout_helper_test.rb
... | ... | @@ -30,4 +30,17 @@ class LayoutHelperTest < ActionView::TestCase |
30 | 30 | assert_match /<link [^<]*href="\/designs\/themes\/my-theme\/global.css"/, css |
31 | 31 | end |
32 | 32 | |
33 | + should 'append javascript files of enabled plugins in noosfero javascripts' do | |
34 | + plugin1 = Noosfero::Plugin.new | |
35 | + plugin1.expects(:js_files).returns(['plugin1.js']) | |
36 | + plugin2 = Noosfero::Plugin.new | |
37 | + plugin2.expects(:js_files).returns('plugin2.js') | |
38 | + @plugins = [plugin1, plugin2] | |
39 | + expects(:environment).returns(Environment.default).at_least_once | |
40 | + expects(:profile).returns(nil).at_least_once | |
41 | + js_tag = noosfero_javascript | |
42 | + assert_match /plugin1\.js/, js_tag | |
43 | + assert_match /plugin2\.js/, js_tag | |
44 | + end | |
45 | + | |
33 | 46 | end | ... | ... |