Commit 05beba715a74c2d58d1e634f0a5c2eae3b861a81

Authored by Larissa Reis
1 parent 413497b7

social-share-privacy: fixes units and functionals tests

  After asset pipeline changes, `javascript_include_tag` doesn't take
  array as argument anymore.
plugins/social_share_privacy/lib/social_share_privacy_plugin.rb
@@ -19,11 +19,13 @@ class SocialSharePrivacyPlugin < Noosfero::Plugin @@ -19,11 +19,13 @@ class SocialSharePrivacyPlugin < Noosfero::Plugin
19 def article_extra_contents(article) 19 def article_extra_contents(article)
20 proc do 20 proc do
21 settings = Noosfero::Plugin::Settings.new(environment, SocialSharePrivacyPlugin) 21 settings = Noosfero::Plugin::Settings.new(environment, SocialSharePrivacyPlugin)
  22 + modules = settings.get_setting(:networks).map { |service| "/plugins/social_share_privacy/socialshareprivacy/javascripts/modules/#{service}.js" }
22 locale = FastGettext.locale 23 locale = FastGettext.locale
23 - javascript_include_tag('plugins/social_share_privacy/socialshareprivacy/javascripts/socialshareprivacy.js') +  
24 - javascript_include_tag('plugins/social_share_privacy/socialshareprivacy/javascripts/localstorage.js') +  
25 - javascript_include_tag(settings.get_setting(:networks).map { |service| "plugins/social_share_privacy/socialshareprivacy/javascripts/modules/#{service}.js" }) +  
26 - (locale != 'en' ? javascript_include_tag("plugins/social_share_privacy/socialshareprivacy/javascripts/locale/jquery.socialshareprivacy.min.#{locale}.js") : '') + 24 + javascript_include_tag('/plugins/social_share_privacy/socialshareprivacy/javascripts/socialshareprivacy.js') +
  25 + javascript_include_tag('/plugins/social_share_privacy/socialshareprivacy/javascripts/localstorage.js') +
  26 + (modules.present? ? javascript_include_tag(*modules) : '') +
  27 + javascript_include_tag("/plugins/social_share_privacy/socialshareprivacy/javascripts/modules/facebook.js") +
  28 + (locale != 'en' ? javascript_include_tag("/plugins/social_share_privacy/socialshareprivacy/javascripts/locale/jquery.socialshareprivacy.min.#{locale}.js") : '') +
27 javascript_tag("jQuery.fn.socialSharePrivacy.settings.path_prefix = '../../plugins/social_share_privacy/socialshareprivacy/'; jQuery.fn.socialSharePrivacy.settings.order = #{settings.get_setting(:networks)}; jQuery(document).ready(function () { jQuery('.social-buttons').socialSharePrivacy({info_link_target: '_blank'});});") + 29 javascript_tag("jQuery.fn.socialSharePrivacy.settings.path_prefix = '../../plugins/social_share_privacy/socialshareprivacy/'; jQuery.fn.socialSharePrivacy.settings.order = #{settings.get_setting(:networks)}; jQuery(document).ready(function () { jQuery('.social-buttons').socialSharePrivacy({info_link_target: '_blank'});});") +
28 content_tag(:div, '', :class => "social-buttons") 30 content_tag(:div, '', :class => "social-buttons")
29 end 31 end
plugins/social_share_privacy/test/functional/content_viewer_controller_test.rb
@@ -23,7 +23,7 @@ class ContentViewerControllerTest < ActionController::TestCase @@ -23,7 +23,7 @@ class ContentViewerControllerTest < ActionController::TestCase
23 23
24 get :view_page, :profile => @profile.identifier, :page => ['test'] 24 get :view_page, :profile => @profile.identifier, :page => ['test']
25 25
26 - assert_tag :tag => 'script', :attributes => {:src => /\/javascripts\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/socialshareprivacy\.js\??\d*/} 26 + assert_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/socialshareprivacy\.js\??\d*/}
27 assert_tag :tag => 'div', :attributes => {:class => "social-buttons"} 27 assert_tag :tag => 'div', :attributes => {:class => "social-buttons"}
28 end 28 end
29 29
@@ -34,8 +34,8 @@ class ContentViewerControllerTest < ActionController::TestCase @@ -34,8 +34,8 @@ class ContentViewerControllerTest < ActionController::TestCase
34 34
35 get :view_page, :profile => @profile.identifier, :page => ['test'] 35 get :view_page, :profile => @profile.identifier, :page => ['test']
36 36
37 - assert_tag :tag => 'script', :attributes => {:src => /\/javascripts\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/modules\/twitter\.js\??\d*/}  
38 - assert_tag :tag => 'script', :attributes => {:src => /\/javascripts\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/modules\/gplus\.js\??\d*/} 37 + assert_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/modules\/twitter\.js\??\d*/}
  38 + assert_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/modules\/gplus\.js\??\d*/}
39 end 39 end
40 40
41 should 'add javascript with string translations if not english' do 41 should 'add javascript with string translations if not english' do
@@ -45,12 +45,12 @@ class ContentViewerControllerTest < ActionController::TestCase @@ -45,12 +45,12 @@ class ContentViewerControllerTest < ActionController::TestCase
45 45
46 get :view_page, :profile => @profile.identifier, :page => ['test'] 46 get :view_page, :profile => @profile.identifier, :page => ['test']
47 47
48 - assert_tag :tag => 'script', :attributes => {:src => /\/javascripts\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/locale\/jquery\.socialshareprivacy\.min\.pt\.js\??\d*/} 48 + assert_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/locale\/jquery\.socialshareprivacy\.min\.pt\.js\??\d*/}
49 49
50 FastGettext.stubs(:locale).returns('en') 50 FastGettext.stubs(:locale).returns('en')
51 51
52 get :view_page, :profile => @profile.identifier, :page => ['test'] 52 get :view_page, :profile => @profile.identifier, :page => ['test']
53 53
54 - assert_no_tag :tag => 'script', :attributes => {:src => /\/javascripts\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/locale\/jquery\.socialshareprivacy\.min\.en\.js\??\d*/} 54 + assert_no_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/locale\/jquery\.socialshareprivacy\.min\.en\.js\??\d*/}
55 end 55 end
56 end 56 end