MS pushing code around into seperate files for clairty, many specs moved around to much more sane names. i still need to break out diaspora generator out of webhooks module
This commit is contained in:
parent
2cbdc5413f
commit
416f128ba8
16 changed files with 197 additions and 215 deletions
|
|
@ -6,7 +6,7 @@ class BlogsController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.atom {render :xml => Diaspora::XML::generate(:current_url => request.url, :objects => @blogs)}
|
format.atom {render :xml => Diaspora::OStatus::generate(:current_url => request.url, :objects => @blogs)}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@ class BookmarksController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.atom {render :xml => Diaspora::XML::generate(:current_url => request.url, :objects => @bookmarks)}
|
format.atom {render :xml => Diaspora::OStatus::generate(:current_url => request.url, :objects => @bookmarks)}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -7,7 +7,7 @@ class StatusMessagesController < ApplicationController
|
||||||
|
|
||||||
respond_to do |format|
|
respond_to do |format|
|
||||||
format.html
|
format.html
|
||||||
format.atom {render :xml => Diaspora::XML::generate(:current_url => request.url, :objects => @status_messages)}
|
format.atom {render :xml => Diaspora::OStatus::generate(:current_url => request.url, :objects => @status_messages)}
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -18,8 +18,8 @@ class Album
|
||||||
|
|
||||||
before_destroy :destroy_photos
|
before_destroy :destroy_photos
|
||||||
after_save :notify_people
|
after_save :notify_people
|
||||||
|
|
||||||
before_destroy :propagate_retraction
|
before_destroy :propagate_retraction
|
||||||
|
|
||||||
def prev_photo(photo)
|
def prev_photo(photo)
|
||||||
n_photo = self.photos.where(:created_at.lt => photo.created_at).sort(:created_at.desc).first
|
n_photo = self.photos.where(:created_at.lt => photo.created_at).sort(:created_at.desc).first
|
||||||
n_photo ? n_photo : self.photos.sort(:created_at.desc).first
|
n_photo ? n_photo : self.photos.sort(:created_at.desc).first
|
||||||
|
|
@ -31,7 +31,6 @@ class Album
|
||||||
end
|
end
|
||||||
|
|
||||||
protected
|
protected
|
||||||
|
|
||||||
def destroy_photos
|
def destroy_photos
|
||||||
photos.each{|p| p.destroy}
|
photos.each{|p| p.destroy}
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -9,4 +9,18 @@ class Blog < Post
|
||||||
|
|
||||||
validates_presence_of :title, :body
|
validates_presence_of :title, :body
|
||||||
|
|
||||||
|
def to_activity
|
||||||
|
<<-XML
|
||||||
|
<entry>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<title>#{self.title}</title>
|
||||||
|
<content>#{self.body}</content>
|
||||||
|
<link rel="alternate" type="text/html" href="#{User.owner.url}blogs/#{self.id}"/>
|
||||||
|
<id>#{User.owner.url}blogs/#{self.id}</id>
|
||||||
|
<published>#{self.created_at.xmlschema}</published>
|
||||||
|
<updated>#{self.updated_at.xmlschema}</updated>
|
||||||
|
</entry>
|
||||||
|
XML
|
||||||
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -14,8 +14,21 @@ class Bookmark < Post
|
||||||
|
|
||||||
before_validation :clean_link
|
before_validation :clean_link
|
||||||
|
|
||||||
protected
|
def to_activity
|
||||||
|
<<-XML
|
||||||
|
<entry>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<title>#{self.title}</title>
|
||||||
|
<link rel="alternate" type="text/html" href="#{User.owner.url}bookmarks/#{self.id}"/>
|
||||||
|
<link rel="related" type="text/html" href="#{self.link}"/>
|
||||||
|
<id>#{User.owner.url}bookmarks/#{self.id}</id>
|
||||||
|
<published>#{self.created_at.xmlschema}</published>
|
||||||
|
<updated>#{self.updated_at.xmlschema}</updated>
|
||||||
|
</entry>
|
||||||
|
XML
|
||||||
|
end
|
||||||
|
|
||||||
|
protected
|
||||||
def clean_link
|
def clean_link
|
||||||
if self.link
|
if self.link
|
||||||
self.link = 'http://' + self.link unless self.link.match('https?://')
|
self.link = 'http://' + self.link unless self.link.match('https?://')
|
||||||
|
|
|
||||||
|
|
@ -5,10 +5,22 @@ class StatusMessage < Post
|
||||||
xml_accessor :message
|
xml_accessor :message
|
||||||
|
|
||||||
key :message, String
|
key :message, String
|
||||||
|
|
||||||
|
|
||||||
validates_presence_of :message
|
validates_presence_of :message
|
||||||
|
|
||||||
|
|
||||||
|
def to_activity
|
||||||
|
<<-XML
|
||||||
|
<entry>
|
||||||
|
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
||||||
|
<title>#{self.message}</title>
|
||||||
|
<link rel="alternate" type="text/html" href="#{User.owner.url}status_messages/#{self.id}"/>
|
||||||
|
<id>#{User.owner.url}status_messages/#{self.id}</id>
|
||||||
|
<published>#{self.created_at.xmlschema}</published>
|
||||||
|
<updated>#{self.updated_at.xmlschema}</updated>
|
||||||
|
</entry>
|
||||||
|
XML
|
||||||
|
end
|
||||||
|
|
||||||
def ==(other)
|
def ==(other)
|
||||||
(self.message == other.message) && (self.person.email == other.person.email)
|
(self.message == other.message) && (self.person.email == other.person.email)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -53,7 +53,7 @@
|
||||||
.span-18.append-3.last
|
.span-18.append-3.last
|
||||||
= yield
|
= yield
|
||||||
.span-3.last
|
.span-3.last
|
||||||
= link_to (image_tag(current_user.profile.image_url)), root_path
|
= link_to (person_image_tag(current_user), root_path)
|
||||||
= link_to "Edit your profile", edit_user_path(current_user)
|
= link_to "Edit your profile", edit_user_path(current_user)
|
||||||
%br
|
%br
|
||||||
%br
|
%br
|
||||||
|
|
|
||||||
70
lib/diaspora/ostatus_generator.rb
Normal file
70
lib/diaspora/ostatus_generator.rb
Normal file
|
|
@ -0,0 +1,70 @@
|
||||||
|
module Diaspora
|
||||||
|
module OStatus
|
||||||
|
def self.generate(opts= {})
|
||||||
|
xml = Generate::headers(opts[:current_url])
|
||||||
|
xml << Generate::author
|
||||||
|
xml << Generate::endpoints
|
||||||
|
xml << Generate::subject
|
||||||
|
xml << Generate::entries(opts[:objects])
|
||||||
|
xml << Generate::footer
|
||||||
|
end
|
||||||
|
|
||||||
|
module Generate
|
||||||
|
def self.headers(current_url)
|
||||||
|
#this is retarded
|
||||||
|
@@user = User.owner
|
||||||
|
<<-XML
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:media="http://purl.org/syndication/atommedia" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:statusnet="http://status.net/schema/api/1/">
|
||||||
|
<generator uri="http://joindiaspora.com/">Diaspora</generator>
|
||||||
|
<id>#{current_url}</id>
|
||||||
|
<title>Stream</title>
|
||||||
|
<subtitle>its a stream </subtitle>
|
||||||
|
<updated>#{Time.now.xmlschema}</updated>
|
||||||
|
XML
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.author
|
||||||
|
<<-XML
|
||||||
|
<author>
|
||||||
|
<name>#{@@user.real_name}</name>
|
||||||
|
<uri>#{@@user.url}</uri>
|
||||||
|
</author>
|
||||||
|
XML
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.endpoints
|
||||||
|
<<-XML
|
||||||
|
<link href="#{APP_CONFIG[:pubsub_server]}" rel="hub"/>
|
||||||
|
XML
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.subject
|
||||||
|
<<-XML
|
||||||
|
<activity:subject>
|
||||||
|
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
|
||||||
|
<id>#{@@user.url}</id>
|
||||||
|
<title>#{@@user.real_name}</title>
|
||||||
|
<link rel="alternative" type="text/html" href="#{@@user.url}"/>
|
||||||
|
</activity:subject>
|
||||||
|
XML
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.entries(objects)
|
||||||
|
xml = ""
|
||||||
|
if objects.respond_to? :each
|
||||||
|
objects.each {|x| xml << x.to_ostatus}
|
||||||
|
else
|
||||||
|
xml << objects.to_activity
|
||||||
|
end
|
||||||
|
xml
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.footer
|
||||||
|
<<-XML.strip
|
||||||
|
</feed>
|
||||||
|
XML
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -57,123 +57,6 @@ module Diaspora
|
||||||
xml += "</posts>"
|
xml += "</posts>"
|
||||||
xml += "</XML>"
|
xml += "</XML>"
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
module XML
|
|
||||||
|
|
||||||
def self.generate(opts= {})
|
|
||||||
xml = Generate::headers(opts[:current_url])
|
|
||||||
xml << Generate::author
|
|
||||||
xml << Generate::endpoints
|
|
||||||
xml << Generate::subject
|
|
||||||
xml << Generate::entries(opts[:objects])
|
|
||||||
xml << Generate::footer
|
|
||||||
end
|
|
||||||
|
|
||||||
module Generate
|
|
||||||
def self.headers(current_url)
|
|
||||||
#this is retarded
|
|
||||||
@@user = User.owner
|
|
||||||
<<-XML
|
|
||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<feed xml:lang="en-US" xmlns="http://www.w3.org/2005/Atom" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:georss="http://www.georss.org/georss" xmlns:activity="http://activitystrea.ms/spec/1.0/" xmlns:media="http://purl.org/syndication/atommedia" xmlns:poco="http://portablecontacts.net/spec/1.0" xmlns:ostatus="http://ostatus.org/schema/1.0" xmlns:statusnet="http://status.net/schema/api/1/">
|
|
||||||
<generator uri="http://joindiaspora.com/">Diaspora</generator>
|
|
||||||
<id>#{current_url}</id>
|
|
||||||
<title>Stream</title>
|
|
||||||
<subtitle>its a stream </subtitle>
|
|
||||||
<updated>#{Time.now.xmlschema}</updated>
|
|
||||||
XML
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.author
|
|
||||||
<<-XML
|
|
||||||
<author>
|
|
||||||
<name>#{@@user.real_name}</name>
|
|
||||||
<uri>#{@@user.url}</uri>
|
|
||||||
</author>
|
|
||||||
XML
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.endpoints
|
|
||||||
<<-XML
|
|
||||||
<link href="#{APP_CONFIG[:pubsub_server]}" rel="hub"/>
|
|
||||||
XML
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.subject
|
|
||||||
<<-XML
|
|
||||||
<activity:subject>
|
|
||||||
<activity:object-type>http://activitystrea.ms/schema/1.0/person</activity:object-type>
|
|
||||||
<id>#{@@user.url}</id>
|
|
||||||
<title>#{@@user.real_name}</title>
|
|
||||||
<link rel="alternative" type="text/html" href="#{@@user.url}"/>
|
|
||||||
</activity:subject>
|
|
||||||
XML
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.entries(objects)
|
|
||||||
xml = ""
|
|
||||||
if objects.respond_to? :each
|
|
||||||
objects.each {|x| xml << self.entry(x)}
|
|
||||||
else
|
|
||||||
xml << self.entry(objects)
|
|
||||||
end
|
|
||||||
xml
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.entry(object)
|
|
||||||
eval "#{object.class}_build_entry(object)"
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.StatusMessage_build_entry(status_message)
|
|
||||||
<<-XML
|
|
||||||
<entry>
|
|
||||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
|
||||||
<title>#{status_message.message}</title>
|
|
||||||
<link rel="alternate" type="text/html" href="#{@@user.url}status_messages/#{status_message.id}"/>
|
|
||||||
<id>#{@@user.url}status_messages/#{status_message.id}</id>
|
|
||||||
<published>#{status_message.created_at.xmlschema}</published>
|
|
||||||
<updated>#{status_message.updated_at.xmlschema}</updated>
|
|
||||||
</entry>
|
|
||||||
XML
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.Bookmark_build_entry(bookmark)
|
|
||||||
<<-XML
|
|
||||||
<entry>
|
|
||||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
|
||||||
<title>#{bookmark.title}</title>
|
|
||||||
<link rel="alternate" type="text/html" href="#{@@user.url}bookmarks/#{bookmark.id}"/>
|
|
||||||
<link rel="related" type="text/html" href="#{bookmark.link}"/>
|
|
||||||
<id>#{@@user.url}bookmarks/#{bookmark.id}</id>
|
|
||||||
<published>#{bookmark.created_at.xmlschema}</published>
|
|
||||||
<updated>#{bookmark.updated_at.xmlschema}</updated>
|
|
||||||
</entry>
|
|
||||||
XML
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
def self.Blog_build_entry(blog)
|
|
||||||
<<-XML
|
|
||||||
<entry>
|
|
||||||
<activity:verb>http://activitystrea.ms/schema/1.0/post</activity:verb>
|
|
||||||
<title>#{blog.title}</title>
|
|
||||||
<content>#{blog.body}</content>
|
|
||||||
<link rel="alternate" type="text/html" href="#{@@user.url}blogs/#{blog.id}"/>
|
|
||||||
<id>#{@@user.url}blogs/#{blog.id}</id>
|
|
||||||
<published>#{blog.created_at.xmlschema}</published>
|
|
||||||
<updated>#{blog.updated_at.xmlschema}</updated>
|
|
||||||
</entry>
|
|
||||||
XML
|
|
||||||
end
|
|
||||||
|
|
||||||
def self.footer
|
|
||||||
<<-XML.strip
|
|
||||||
</feed>
|
|
||||||
XML
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,6 @@ require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
describe DashboardsController do
|
describe DashboardsController do
|
||||||
render_views
|
render_views
|
||||||
|
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith"))
|
@user = Factory.create(:user, :profile => Profile.new( :first_name => "bob", :last_name => "smith"))
|
||||||
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
request.env['warden'] = mock_model(Warden, :authenticate? => @user, :authenticate! => @user, :authenticate => @user)
|
||||||
|
|
|
||||||
|
|
@ -1,16 +1,18 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
describe Diaspora::XML do
|
require 'lib/diaspora/ostatus_generator'
|
||||||
|
|
||||||
|
describe Diaspora::OStatus do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user)
|
@user = Factory.create(:user)
|
||||||
Diaspora::XML::OWNER = @user
|
Diaspora::OStatus::OWNER = @user
|
||||||
end
|
end
|
||||||
|
|
||||||
describe Diaspora::XML::Generate do
|
describe Diaspora::OStatus::Generate do
|
||||||
|
|
||||||
describe "header" do
|
describe "header" do
|
||||||
it 'should generate an OStatus compliant header' do
|
it 'should generate an OStatus compliant header' do
|
||||||
Diaspora::XML::Generate::headers(:current_url => @user.url).should include @user.url
|
Diaspora::OStatus::Generate::headers(:current_url => @user.url).should include @user.url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
@ -20,7 +22,7 @@ describe Diaspora::XML do
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should encode to activity stream xml" do
|
it "should encode to activity stream xml" do
|
||||||
sm_entry = Diaspora::XML::generate(:objects => @status_message, :current_url => "http://diaspora.com/")
|
sm_entry = Diaspora::OStatus::generate(:objects => @status_message, :current_url => "http://diaspora.com/")
|
||||||
sm_entry.should include(@status_message.message)
|
sm_entry.should include(@status_message.message)
|
||||||
sm_entry.should include('title')
|
sm_entry.should include('title')
|
||||||
end
|
end
|
||||||
|
|
@ -1,9 +1,8 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
include ApplicationHelper
|
include ApplicationHelper
|
||||||
include Diaspora::OStatusParser
|
|
||||||
|
|
||||||
describe "parser in application helper" do
|
describe Diaspora::DiasporaParser do
|
||||||
before do
|
before do
|
||||||
@user = Factory.create(:user, :email => "bob@aol.com")
|
@user = Factory.create(:user, :email => "bob@aol.com")
|
||||||
@person = Factory.create(:person, :email => "bill@gates.com")
|
@person = Factory.create(:person, :email => "bill@gates.com")
|
||||||
|
|
@ -60,77 +59,6 @@ describe "parser in application helper" do
|
||||||
Post.count.should == 0
|
Post.count.should == 0
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'ostatus parsing' do
|
|
||||||
it 'should be able to get the hub of an ostatus feed' do
|
|
||||||
xml_path = File.dirname(__FILE__) + '/../fixtures/identica_feed.atom'
|
|
||||||
xml = File.open(xml_path).read
|
|
||||||
|
|
||||||
Diaspora::OStatusParser::find_hub(xml).should == 'http://identi.ca/main/push/hub'
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
describe 'subscriber info' do
|
|
||||||
before do
|
|
||||||
#load file
|
|
||||||
xml_path = File.dirname(__FILE__) + '/../fixtures/ostatus_update.xml'
|
|
||||||
@xml = File.open(xml_path).read
|
|
||||||
@xml = Nokogiri::HTML(@xml)
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
it 'should parse the users service' do
|
|
||||||
Diaspora::OStatusParser::parse_service(@xml).should == 'StatusNet'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should parse the feed_url' do
|
|
||||||
Diaspora::OStatusParser::parse_feed_url(@xml).should == 'http://identi.ca/api/statuses/user_timeline/217769.atom'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should parse the avatar thumbnail' do
|
|
||||||
Diaspora::OStatusParser::parse_avatar_thumbnail(@xml).should == 'http://theme.status.net/0.9.3/identica/default-avatar-profile.png'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should parse the username' do
|
|
||||||
Diaspora::OStatusParser::parse_username(@xml).should == 'danielgrippi'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should parse the profile_url' do
|
|
||||||
Diaspora::OStatusParser::parse_profile_url(@xml).should == 'http://identi.ca/user/217769'
|
|
||||||
end
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
describe 'entry' do
|
|
||||||
before do
|
|
||||||
#load file
|
|
||||||
xml_path = File.dirname(__FILE__) + '/../fixtures/ostatus_update.xml'
|
|
||||||
@xml = File.open(xml_path).read
|
|
||||||
@xml = Nokogiri::HTML(@xml)
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should parse the message' do
|
|
||||||
Diaspora::OStatusParser::parse_message(@xml).should == 'SOAP!'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should parse the permalink' do
|
|
||||||
Diaspora::OStatusParser::parse_permalink(@xml).should == 'http://identi.ca/notice/43074747'
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should parse published at date' do
|
|
||||||
Diaspora::OStatusParser::parse_published_at(@xml).should == '2010-07-22T22:15:31+00:00'
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
it 'should parse the updated at date' do
|
|
||||||
Diaspora::OStatusParser::parse_updated_at(@xml).should == '2010-07-22T22:15:31+00:00'
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
end
|
|
||||||
|
|
||||||
describe "parsing compliant XML object" do
|
describe "parsing compliant XML object" do
|
||||||
before do
|
before do
|
||||||
|
|
@ -224,7 +152,6 @@ describe "parser in application helper" do
|
||||||
Person.count.should == 1
|
Person.count.should == 1
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
68
spec/lib/ostatus_parser_spec.rb
Normal file
68
spec/lib/ostatus_parser_spec.rb
Normal file
|
|
@ -0,0 +1,68 @@
|
||||||
|
require File.dirname(__FILE__) + '/../spec_helper'
|
||||||
|
|
||||||
|
describe Diaspora::OStatusParser do
|
||||||
|
it 'should be able to get the hub of an ostatus feed' do
|
||||||
|
xml_path = File.dirname(__FILE__) + '/../fixtures/identica_feed.atom'
|
||||||
|
xml = File.open(xml_path).read
|
||||||
|
|
||||||
|
Diaspora::OStatusParser::find_hub(xml).should == 'http://identi.ca/main/push/hub'
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
describe 'subscriber info' do
|
||||||
|
before do
|
||||||
|
#load file
|
||||||
|
xml_path = File.dirname(__FILE__) + '/../fixtures/ostatus_update.xml'
|
||||||
|
@xml = File.open(xml_path).read
|
||||||
|
@xml = Nokogiri::HTML(@xml)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
|
it 'should parse the users service' do
|
||||||
|
Diaspora::OStatusParser::parse_service(@xml).should == 'StatusNet'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse the feed_url' do
|
||||||
|
Diaspora::OStatusParser::parse_feed_url(@xml).should == 'http://identi.ca/api/statuses/user_timeline/217769.atom'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse the avatar thumbnail' do
|
||||||
|
Diaspora::OStatusParser::parse_avatar_thumbnail(@xml).should == 'http://theme.status.net/0.9.3/identica/default-avatar-profile.png'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse the username' do
|
||||||
|
Diaspora::OStatusParser::parse_username(@xml).should == 'danielgrippi'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse the profile_url' do
|
||||||
|
Diaspora::OStatusParser::parse_profile_url(@xml).should == 'http://identi.ca/user/217769'
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'entry' do
|
||||||
|
before do
|
||||||
|
#load file
|
||||||
|
xml_path = File.dirname(__FILE__) + '/../fixtures/ostatus_update.xml'
|
||||||
|
@xml = File.open(xml_path).read
|
||||||
|
@xml = Nokogiri::HTML(@xml)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse the message' do
|
||||||
|
Diaspora::OStatusParser::parse_message(@xml).should == 'SOAP!'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse the permalink' do
|
||||||
|
Diaspora::OStatusParser::parse_permalink(@xml).should == 'http://identi.ca/notice/43074747'
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse published at date' do
|
||||||
|
Diaspora::OStatusParser::parse_published_at(@xml).should == '2010-07-22T22:15:31+00:00'
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'should parse the updated at date' do
|
||||||
|
Diaspora::OStatusParser::parse_updated_at(@xml).should == '2010-07-22T22:15:31+00:00'
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -1,5 +0,0 @@
|
||||||
require File.dirname(__FILE__) + '/../spec_helper'
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Loading…
Reference in a new issue