* Adds a new metadata helper and methods to PostPresenter to have metas on post pages. * Adds tests to post controller to check correctness of metas * Add methods to PersonPresenter to have metas on profile pages * Correct meta data helper test * Update PersonPresenter, add test to PeopleController * Creates TagPresenter. Display tag metas on tag index page * Updata meta data helper spec * Not displaying bio as the description meta on profile page for now. Privacy concerns to be cleared. * Set meta info as hashes in presenters * Move original hardcoded metas info to config/defaults.yml * metas_tags include by default the general metas, update views * Update code style, clean views * Renames TagPresenter StreamTagPresenter, updates TagController spec * Add a default_metas entry to diaspora.yml.example * Align metas hash in presenters, refactor meta data helper * Use bio as description meta if user has a public profile * Rename StreamTagPresenter to TagStreamPresenter
55 lines
2.3 KiB
Ruby
55 lines
2.3 KiB
Ruby
require "spec_helper"
|
|
|
|
describe MetaDataHelper, type: :helper do
|
|
describe "#meta_tag" do
|
|
it "returns an empty string if passed an empty hash" do
|
|
expect(meta_tag({})).to eq("")
|
|
end
|
|
|
|
it "returns a meta tag with the passed attributes" do
|
|
attributes = {name: "test", content: "foo"}
|
|
expect(meta_tag(attributes)).to eq('<meta name="test" content="foo" />')
|
|
end
|
|
|
|
it "returns a list of the same meta type if the value for :content in the passed attribute is an array" do
|
|
attributes = {property: "og:tag", content: %w(tag_1 tag_2)}
|
|
expect(meta_tag(attributes)).to eq(
|
|
%(<meta property="og:tag" content="tag_1" />\n) +
|
|
%(<meta property="og:tag" content="tag_2" />)
|
|
)
|
|
end
|
|
end
|
|
|
|
describe '#metas_tags' do
|
|
before do
|
|
@attributes = {
|
|
description: {name: "description", content: "i am a test"},
|
|
og_website: {property: "og:website", content: "http://www.test2.com"}
|
|
}
|
|
default_attributes = {
|
|
description: {name: "description", content: "default description"},
|
|
og_url: {property: "og:url", content: "http://www.defaulturl.com"}
|
|
}
|
|
allow(helper).to receive(:general_metas).and_return(default_attributes)
|
|
end
|
|
|
|
it "returns the default meta datas if passed nothing" do
|
|
metas_html = %(<meta name="description" content="default description" />\n) +
|
|
%(<meta property="og:url" content="http://www.defaulturl.com" />)
|
|
expect(helper.metas_tags).to eq(metas_html)
|
|
end
|
|
|
|
it "combines by default the general meta datas with the passed attributes" do
|
|
metas_html = %(<meta name="description" content="i am a test" />\n) +
|
|
%(<meta property="og:url" content="http://www.defaulturl.com" />\n) +
|
|
%(<meta property="og:website" content="http://www.test2.com" />)
|
|
expect(helper.metas_tags(@attributes)).to eq(metas_html)
|
|
end
|
|
|
|
it "does not combines the general meta datas with the passed attributes if option is disabled" do
|
|
default_metas_html = %(<meta name="description" content="default description" />\n) +
|
|
%(<meta property="og:url" content="http://www.defaulturl.com" />)
|
|
expect(helper.metas_tags(@attributes, false)).not_to include(default_metas_html)
|
|
end
|
|
end
|
|
end
|