2 more specs failing. wip

This commit is contained in:
danielgrippi 2011-07-14 19:08:03 -07:00 committed by Raphael Sofaer
parent a32ef3c1d8
commit a8400ad460
2 changed files with 38 additions and 19 deletions

View file

@ -39,11 +39,17 @@ class Reshare < Post
root_author = Webfinger.new(@root_diaspora_id).fetch
root_author.save!
unless self.root = Post.where(:guid => @root_guid).first
self.root = Diaspora::Parser.from_xml(Faraday.get(root_author.url + "/p/#{@root_guid}.xml").body)
self.root.save!
local_post = Post.where(:guid => @root_guid).select('id').first
unless local_post && self.root_id = local_post.id
received_post = Diaspora::Parser.from_xml(Faraday.get(root_author.url + "/p/#{@root_guid}.xml").body)
unless post = received_post.class.where(:guid => received_post.guid).first
post = received_post
post.save
end
self.root_id = post.id
end
end
def root_must_be_public

View file

@ -78,21 +78,11 @@ describe Reshare do
@root_object = @reshare.root.delete
end
it 'fetches the root post from root_guid' do
response = mock
response.stub(:body).and_return(@root_object.to_diaspora_xml)
Faraday.default_connection.should_receive(:get).with(@reshare.root.author.url + public_post_path(:guid => @root_object.guid, :format => "xml")).and_return(response)
root = Reshare.from_xml(@xml).root
[:text, :guid, :diaspora_handle, :type].each do |attr|
root.send(attr).should == @reshare.root.send(attr)
end
end
it 'fetches the root author from root_diaspora_id' do
@original_profile = @reshare.root.author.profile
@original_author = @reshare.root.author.delete
@original_profile = @reshare.root.author.profile.dup
@reshare.root.author.profile.delete
@original_author = @reshare.root.author.dup
@reshare.root.author.delete
wf_prof_mock = mock
wf_prof_mock.should_receive(:fetch).and_return(@original_author)
@ -102,9 +92,32 @@ describe Reshare do
response.stub(:body).and_return(@root_object.to_diaspora_xml)
Faraday.default_connection.should_receive(:get).with(@original_author.url + public_post_path(:guid => @root_object.guid, :format => "xml")).and_return(response)
Reshare.from_xml(@xml)
end
context 'saving the post' do
before do
response = mock
response.stub(:body).and_return(@root_object.to_diaspora_xml)
Faraday.default_connection.should_receive(:get).with(@reshare.root.author.url + public_post_path(:guid => @root_object.guid, :format => "xml")).and_return(response)
end
it 'fetches the root post from root_guid' do
root = Reshare.from_xml(@xml).root
[:text, :guid, :diaspora_handle, :type, :public].each do |attr|
root.send(attr).should == @reshare.root.send(attr)
end
end
it 'correctly saves the type' do
Reshare.from_xml(@xml).root.reload.type.should == "StatusMessage"
end
it 'correctly sets the author' do
Reshare.from_xml(@xml).root.reload.author.reload.should == @original_author
end
end
end
end
end