From e7828dcae88911d64afc64de5b5a5def33ea6003 Mon Sep 17 00:00:00 2001 From: The Lambda Calculus Date: Tue, 11 Oct 2011 01:43:11 -0400 Subject: [PATCH] Squashed commit of the following: commit 740296e86fdd080e6e787c5c024a6b609782d82f Author: The Lambda Calculus Date: Mon Oct 10 16:49:35 2011 -0400 Wrote rspec for atom feed validation. [Finishes issue #1408] commit e2999cbe588bcb32f35f05120743627cf3b31f56 Author: The Lambda Calculus Date: Thu Sep 29 18:28:14 2011 -0400 Adjusted placement of invalid 'link' elements outside of 'author' element. Feed now validates, though warnings/suggestions still exist. [Issue #1408] --- lib/diaspora/ostatus_builder.rb | 4 +- spec/lib/diaspora/atom.rng | 598 ++++++++++++++++++++++ spec/lib/diaspora/ostatus_builder_spec.rb | 13 +- 3 files changed, 612 insertions(+), 3 deletions(-) create mode 100644 spec/lib/diaspora/atom.rng diff --git a/lib/diaspora/ostatus_builder.rb b/lib/diaspora/ostatus_builder.rb index 7242fe35e..57936396f 100644 --- a/lib/diaspora/ostatus_builder.rb +++ b/lib/diaspora/ostatus_builder.rb @@ -45,16 +45,16 @@ module Diaspora http://activitystrea.ms/schema/1.0/person #{x(@user.name)} #{AppConfig[:pod_url]}people/#{@user.person.id} - #{x(@user.username)} #{x(@user.person.name)} - XML end def create_endpoints <<-XML + + XML diff --git a/spec/lib/diaspora/atom.rng b/spec/lib/diaspora/atom.rng new file mode 100644 index 000000000..c372db608 --- /dev/null +++ b/spec/lib/diaspora/atom.rng @@ -0,0 +1,598 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text + html + + + + + + + + + xhtml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + An atom:feed must have an atom:author unless all of its atom:entry children have an atom:author. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + An atom:entry must have at least one atom:link element with a rel attribute of 'alternate' or an atom:content. + + + An atom:entry must have an atom:author if its feed does not. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text + html + + + + + + + + + + + + + xhtml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 1 + [^:]* + + + + + + .+/.+ + + + + + + [A-Za-z]{1,8}(-[A-Za-z0-9]{1,8})* + + + + + + + + + + .+@.+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + xml:base + xml:lang + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/spec/lib/diaspora/ostatus_builder_spec.rb b/spec/lib/diaspora/ostatus_builder_spec.rb index 1ed2b48ce..256cbf223 100644 --- a/spec/lib/diaspora/ostatus_builder_spec.rb +++ b/spec/lib/diaspora/ostatus_builder_spec.rb @@ -4,7 +4,7 @@ require 'spec_helper' require File.join(Rails.root, 'lib/diaspora/ostatus_builder') - +require 'nokogiri/xml' describe Diaspora::OstatusBuilder do @@ -46,5 +46,16 @@ describe Diaspora::OstatusBuilder do director.build( builder ) report_hash["Person"].should be_nil #No people should have been instantiated end + + it 'produces a valid atom feed' do + alice.person #Preload user.person + ActiveRecord::Base.reset_instance_type_count + director = Diaspora::Director.new + messages = StatusMessage.where(:author_id => alice.person.id, :public => true) + builder = Diaspora::OstatusBuilder.new(alice, messages) + feed = Nokogiri::XML(director.build( builder )) + feed_schema = Nokogiri::XML::RelaxNG(File.open(File.join(Rails.root,'spec/lib/diaspora/atom.rng'))) + feed_schema.validate(feed).should be_empty + end end