Adding more tests for helpers
parent
b640f35621
commit
253ab26520
|
@ -3,7 +3,7 @@ module AtomBuilderHelper
|
||||||
@account.stream_entries.last ? (@account.updated_at > @account.stream_entries.last.created_at ? @account.updated_at : @account.stream_entries.last.created_at) : @account.updated_at
|
@account.stream_entries.last ? (@account.updated_at > @account.stream_entries.last.created_at ? @account.updated_at : @account.stream_entries.last.created_at) : @account.updated_at
|
||||||
end
|
end
|
||||||
|
|
||||||
def entry(xml, is_root, &block)
|
def entry(xml, is_root = false, &block)
|
||||||
if is_root
|
if is_root
|
||||||
root_tag(xml, :entry, &block)
|
root_tag(xml, :entry, &block)
|
||||||
else
|
else
|
||||||
|
|
|
@ -15,6 +15,7 @@ Rails.application.configure do
|
||||||
# Configure static file server for tests with Cache-Control for performance.
|
# Configure static file server for tests with Cache-Control for performance.
|
||||||
config.serve_static_files = true
|
config.serve_static_files = true
|
||||||
config.static_cache_control = 'public, max-age=3600'
|
config.static_cache_control = 'public, max-age=3600'
|
||||||
|
config.assets.digest = false
|
||||||
|
|
||||||
# Show full error reports and disable caching.
|
# Show full error reports and disable caching.
|
||||||
config.consider_all_requests_local = true
|
config.consider_all_requests_local = true
|
||||||
|
|
|
@ -6,95 +6,148 @@ RSpec.describe AtomBuilderHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#entry' do
|
describe '#entry' do
|
||||||
pending
|
it 'creates an entry' do
|
||||||
|
expect(used_in_builder { |xml| helper.entry(xml) }).to match '<entry/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#feed' do
|
describe '#feed' do
|
||||||
pending
|
it 'creates a feed' do
|
||||||
|
expect(used_in_builder { |xml| helper.feed(xml) }).to match '<feed xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:media="http://purl.org/syndication/atommedia"/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#unique_id' do
|
describe '#unique_id' do
|
||||||
pending
|
it 'creates an id' do
|
||||||
|
time = Time.now
|
||||||
|
expect(used_in_builder { |xml| helper.unique_id(xml, time, 1, 'Status') }).to match "<id>#{helper.unique_tag(time, 1, 'Status')}</id>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#simple_id' do
|
describe '#simple_id' do
|
||||||
pending
|
it 'creates an id' do
|
||||||
|
expect(used_in_builder { |xml| helper.simple_id(xml, 1) }).to match '<id>1</id>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#published_at' do
|
describe '#published_at' do
|
||||||
pending
|
it 'creates a published tag' do
|
||||||
|
time = Time.now
|
||||||
|
expect(used_in_builder { |xml| helper.published_at(xml, time) }).to match "<published>#{time.iso8601}</published>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#updated_at' do
|
describe '#updated_at' do
|
||||||
pending
|
it 'creates an updated tag' do
|
||||||
|
time = Time.now
|
||||||
|
expect(used_in_builder { |xml| helper.updated_at(xml, time) }).to match "<updated>#{time.iso8601}</updated>"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#verb' do
|
describe '#verb' do
|
||||||
pending
|
it 'creates an entry' do
|
||||||
|
expect(used_with_namespaces { |xml| helper.verb(xml, 'verb') }).to match '<activity:verb>http://activitystrea.ms/schema/1.0/verb</activity:verb>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#content' do
|
describe '#content' do
|
||||||
pending
|
it 'creates a content' do
|
||||||
|
expect(used_in_builder { |xml| helper.content(xml, 'foo') }).to match '<content type="html">foo</content>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#title' do
|
describe '#title' do
|
||||||
pending
|
it 'creates a title' do
|
||||||
|
expect(used_in_builder { |xml| helper.title(xml, 'foo') }).to match '<title>foo</title>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#author' do
|
describe '#author' do
|
||||||
pending
|
it 'creates an author' do
|
||||||
|
expect(used_in_builder { |xml| helper.author(xml) }).to match '<author/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#target' do
|
describe '#target' do
|
||||||
pending
|
it 'creates a target' do
|
||||||
|
expect(used_with_namespaces { |xml| helper.target(xml) }).to match '<activity:object/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#object_type' do
|
describe '#object_type' do
|
||||||
pending
|
it 'creates an object type' do
|
||||||
|
expect(used_with_namespaces { |xml| helper.object_type(xml, 'test') }).to match '<activity:object-type>http://activitystrea.ms/schema/1.0/test</activity:object-type>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#uri' do
|
describe '#uri' do
|
||||||
pending
|
it 'creates a uri' do
|
||||||
|
expect(used_in_builder { |xml| helper.uri(xml, 1) }).to match '<uri>1</uri>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#name' do
|
describe '#name' do
|
||||||
pending
|
it 'creates a name' do
|
||||||
|
expect(used_in_builder { |xml| helper.name(xml, 1) }).to match '<name>1</name>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#summary' do
|
describe '#summary' do
|
||||||
pending
|
it 'creates a summary' do
|
||||||
|
expect(used_in_builder { |xml| helper.summary(xml, 1) }).to match '<summary>1</summary>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#subtitle' do
|
describe '#subtitle' do
|
||||||
pending
|
it 'creates a subtitle' do
|
||||||
|
expect(used_in_builder { |xml| helper.subtitle(xml, 1) }).to match '<subtitle>1</subtitle>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#link_alternate' do
|
describe '#link_alternate' do
|
||||||
pending
|
it 'creates a link' do
|
||||||
|
expect(used_in_builder { |xml| helper.link_alternate(xml, 1) }).to match '<link rel="alternate" type="text/html" href="1"/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#link_self' do
|
describe '#link_self' do
|
||||||
pending
|
it 'creates a link' do
|
||||||
|
expect(used_in_builder { |xml| helper.link_self(xml, 1) }).to match '<link rel="self" type="application/atom+xml" href="1"/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#link_hub' do
|
describe '#link_hub' do
|
||||||
pending
|
it 'creates a link' do
|
||||||
|
expect(used_in_builder { |xml| helper.link_hub(xml, 1) }).to match '<link rel="hub" href="1"/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#link_salmon' do
|
describe '#link_salmon' do
|
||||||
pending
|
it 'creates a link' do
|
||||||
|
expect(used_in_builder { |xml| helper.link_salmon(xml, 1) }).to match '<link rel="salmon" href="1"/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#portable_contact' do
|
describe '#portable_contact' do
|
||||||
pending
|
let(:account) { Fabricate(:account, username: 'alice', display_name: 'Alice in Wonderland') }
|
||||||
|
|
||||||
|
it 'creates portable contacts entries' do
|
||||||
|
expect(used_with_namespaces { |xml| helper.portable_contact(xml, account) }).to match '<poco:displayName>Alice in Wonderland</poco:displayName>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#in_reply_to' do
|
describe '#in_reply_to' do
|
||||||
pending
|
it 'creates a thread' do
|
||||||
|
expect(used_with_namespaces { |xml| helper.in_reply_to(xml, 'uri', 'url') }).to match '<thr:in-reply-to ref="uri" href="url" type="text/html"/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#link_mention' do
|
describe '#link_mention' do
|
||||||
pending
|
let(:account) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
it 'creates a link' do
|
||||||
|
expect(used_in_builder { |xml| helper.link_mention(xml, account) }).to match '<link rel="mentioned" href="http://test.host/users/alice"/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#disambiguate_uri' do
|
describe '#disambiguate_uri' do
|
||||||
|
@ -114,10 +167,25 @@ RSpec.describe AtomBuilderHelper, type: :helper do
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#link_avatar' do
|
describe '#link_avatar' do
|
||||||
pending
|
let(:account) { Fabricate(:account, username: 'alice') }
|
||||||
|
|
||||||
|
it 'creates a link' do
|
||||||
|
expect(used_with_namespaces { |xml| helper.link_avatar(xml, account) }).to match '<link rel="avatar" type="" media:width="300" media:height="300" href="http://test.host/assets/avatars/missing.png"/>'
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe '#logo' do
|
describe '#logo' do
|
||||||
pending
|
it 'creates a logo' do
|
||||||
|
expect(used_in_builder { |xml| helper.logo(xml, 1) }).to match '<logo>1</logo>'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def used_in_builder(&block)
|
||||||
|
builder = Nokogiri::XML::Builder.new(&block)
|
||||||
|
builder.doc.root.to_xml
|
||||||
|
end
|
||||||
|
|
||||||
|
def used_with_namespaces(&block)
|
||||||
|
used_in_builder { |xml| helper.entry(xml, true, &block) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue