# encoding: UTF-8 require 'test_helper' require 'content_viewer_controller' class ContentViewerControllerTest < ActionController::TestCase def setup @controller = ContentViewerController.new @request = ActionController::TestRequest.new @response = ActionController::TestResponse.new @profile = create_user('testinguser').person @environment = @profile.environment @environment.enabled_plugins += ['MetadataPlugin'] @environment.save! end attr_reader :profile, :environment should 'produce meta tags for profile if on homepage' do get :view_page, profile: profile.identifier, page: [] assert_tag tag: 'meta', attributes: {property: 'og:title', content: profile.name} end should 'add meta tags with article info' do a = TinyMceArticle.create(name: 'Article to be shared', body: '
This article should be shared with all social networks
', profile: profile) get :view_page, profile: profile.identifier, page: [ a.name.to_slug ] assert_tag tag: 'meta', attributes: { name: 'twitter:title', content: /#{a.name} - #{a.profile.name}/ } assert_tag tag: 'meta', attributes: { name: 'twitter:description', content: a.lead.gsub(/<\/?p>/,'') } assert_no_tag tag: 'meta', attributes: { name: 'twitter:image' } assert_tag tag: 'meta', attributes: { property: 'og:type', content: 'article' } assert_tag tag: 'meta', attributes: { property: 'og:url', content: /\/#{profile.identifier}\/#{a.name.to_slug}/ } assert_tag tag: 'meta', attributes: { property: 'og:title', content: /#{a.name} - #{a.profile.name}/ } assert_tag tag: 'meta', attributes: { property: 'og:site_name', content: a.profile.name } assert_tag tag: 'meta', attributes: { property: 'og:description', content: a.lead.gsub(/<\/?p>/,'') } assert_no_tag tag: 'meta', attributes: { property: 'og:image' } end should 'add meta tags with article images' do a = TinyMceArticle.create(name: 'Article to be shared with images', body: 'This article should be shared with all social networks