Merge pull request #2153 from consul/social-meta-tags

Social meta tags
This commit is contained in:
BertoCQ
2017-11-29 10:54:05 +01:00
committed by GitHub
8 changed files with 74 additions and 11 deletions

View File

@@ -153,8 +153,8 @@ feature 'Proposals' do
proposal = create(:proposal)
visit proposal_path(proposal)
expect(page.html).to include "<meta name=\"twitter:title\" content=\"#{proposal.title}\" />"
expect(page.html).to include "<meta id=\"ogtitle\" property=\"og:title\" content=\"#{proposal.title}\"/>"
expect(page).to have_css "meta[name='twitter:title'][content=\"#{proposal.title}\"]", visible: false
expect(page).to have_css "meta[property='og:title'][content=\"#{proposal.title}\"]", visible: false
end
scenario 'Create' do

View File

@@ -0,0 +1,54 @@
require 'rails_helper'
feature 'Social media meta tags' do
context 'Setting social media meta tags' do
let(:meta_keywords) { 'citizen, participation, open government' }
let(:meta_title) { 'CONSUL TEST' }
let(:meta_description) { 'Citizen Participation and Open Government Application' }
let(:twitter_handle) { '@consul_test' }
let(:url) { 'http://consul.dev' }
let(:facebook_handle) { 'consultest' }
let(:org_name) { 'CONSUL TEST' }
before do
Setting['meta_keywords'] = meta_keywords
Setting['meta_title'] = meta_title
Setting['meta_description'] = meta_description
Setting['twitter_handle'] = twitter_handle
Setting['url'] = url
Setting['facebook_handle'] = facebook_handle
Setting['org_name'] = org_name
end
after do
Setting['meta_keywords'] = nil
Setting['meta_title'] = nil
Setting['meta_description'] = nil
Setting['twitter_handle'] = nil
Setting['url'] = 'http://example.com'
Setting['facebook_handle'] = nil
Setting['org_name'] = 'CONSUL'
end
scenario 'Social media meta tags partial render settings content' do
visit root_path
expect(page).to have_css 'meta[name="keywords"][content="'+ meta_keywords + '"]', visible: false
expect(page).to have_css 'meta[name="twitter:site"][content="'+ twitter_handle + '"]', visible: false
expect(page).to have_css 'meta[name="twitter:title"][content="'+ meta_title + '"]', visible: false
expect(page).to have_css 'meta[name="twitter:description"][content="' + meta_description + '"]', visible: false
expect(page).to have_css 'meta[name="twitter:image"][content="http://www.example.com/social_media_icon_twitter.png"]', visible: false
expect(page).to have_css 'meta[property="og:title"][content="'+ meta_title + '"]', visible: false
expect(page).to have_css 'meta[property="article:publisher"][content="' + url + '"]', visible: false
expect(page).to have_css 'meta[property="article:author"][content="https://www.facebook.com/' + facebook_handle + '"]', visible: false
expect(page).to have_css 'meta[property="og:url"][content="http://www.example.com/"]', visible: false
expect(page).to have_css 'meta[property="og:image"][content="http://www.example.com/social_media_icon.png"]', visible: false
expect(page).to have_css 'meta[property="og:site_name"][content="' + org_name + '"]', visible: false
expect(page).to have_css 'meta[property="og:description"][content="' + meta_description + '"]', visible: false
end
end
end