ref: master
plugins/social_share_privacy/test/functional/content_viewer_controller_test.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 |
require 'test_helper' require_relative '../../../../app/controllers/public/invite_controller' class ContentViewerControllerTest < ActionController::TestCase def setup @controller = ContentViewerController.new @profile = create_user('testinguser').person @environment = @profile.environment @environment.enabled_plugins = ['SocialSharePrivacyPlugin'] @environment.save! end should 'add social content on content view page' do page = @profile.articles.build(:name => 'test') page.save! get :view_page, :profile => @profile.identifier, :page => ['test'] assert_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/socialshareprivacy\.js\??\d*/} assert_tag :tag => 'div', :attributes => {:class => "social-buttons"} end should 'add social share privacy modules acording to networks settings' do page = @profile.articles.build(:name => 'test') page.save! Noosfero::Plugin::Settings.new(@environment, SocialSharePrivacyPlugin, :networks => ['twitter', 'gplus']).save! get :view_page, :profile => @profile.identifier, :page => ['test'] assert_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/modules\/twitter\.js\??\d*/} assert_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/modules\/gplus\.js\??\d*/} end should 'add javascript with string translations if not english' do page = @profile.articles.build(:name => 'test') page.save! FastGettext.stubs(:locale).returns('pt') get :view_page, :profile => @profile.identifier, :page => ['test'] assert_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/locale\/jquery\.socialshareprivacy\.min\.pt\.js\??\d*/} FastGettext.stubs(:locale).returns('en') get :view_page, :profile => @profile.identifier, :page => ['test'] assert_no_tag :tag => 'script', :attributes => {:src => /\/plugins\/social_share_privacy\/socialshareprivacy\/javascripts\/locale\/jquery\.socialshareprivacy\.min\.en\.js\??\d*/} end end |