Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/diaspora/diaspora.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/spec
diff options
context:
space:
mode:
authordanielgrippi <danielgrippi@gmail.com>2011-07-14 06:40:08 +0400
committerRaphael Sofaer <raphael@joindiaspora.com>2011-07-22 05:22:17 +0400
commit509a435cc9c6b608923b3a03347584bda76be5e7 (patch)
tree8aae4415231320a0b0d0777a1093235cdce1cfb8 /spec
parent7b3180e5da4a6dab67e543f237b3a9b6de1bc72f (diff)
moving to not including the post in the reshare xml
Diffstat (limited to 'spec')
-rw-r--r--spec/models/reshare_spec.rb67
1 files changed, 67 insertions, 0 deletions
diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb
index 523f6cc78..10b93d261 100644
--- a/spec/models/reshare_spec.rb
+++ b/spec/models/reshare_spec.rb
@@ -1,6 +1,13 @@
require 'spec_helper'
describe Reshare do
+ include ActionView::Helpers::UrlHelper
+ include Rails.application.routes.url_helpers
+ def controller
+ mock()
+ end
+
+
it 'has a valid Factory' do
Factory(:reshare).should be_valid
end
@@ -33,4 +40,64 @@ describe Reshare do
@root.resharers.should include(@reshare.author)
end
end
+
+ describe "XML" do
+ before do
+ @reshare = Factory(:reshare)
+ @xml = @reshare.to_xml.to_s
+ pp @xml
+ end
+
+ context 'serialization' do
+ it 'serializes root_diaspora_id' do
+ @xml.should include("root_diaspora_id")
+ end
+
+ it 'serializes root_guid' do
+ @xml.should include("root_guid")
+ end
+ end
+
+ context 'marshalling' do
+ context 'local' do
+ before do
+ @original_author = @reshare.root.author.dup
+ @root_object = @reshare.root.dup
+ end
+
+ it 'fetches the root post from root_guid' do
+ Reshare.from_xml(@xml).root.should == @root_object
+ end
+
+ it 'fetches the root author from root_diaspora_id' do
+ Reshare.from_xml(@xml).root.author.should == @original_author
+ end
+ end
+
+ context 'remote' do
+ before do
+ @original_profile = @reshare.root.author.profile
+ @original_author = @reshare.root.author.delete
+ @root_object = @reshare.root.delete
+ end
+
+ it 'fetches the root post from root_guid' do
+ @original_profile.save!
+ pp @original_profile
+ @original_author.save!
+ pp @original_author
+ Faraday.should_receive(:get).with(@original_author.url + public_post_path(:guid => @reshare.guid)).and_return(@root_object.to_diaspora_xml)
+ Reshare.from_xml(@xml).root.should == @root_object
+ end
+
+ it 'fetches the root author from root_diaspora_id' do
+ person = Factory.build(:person)
+ wf_prof_mock = mock
+ wf_prof_mock.should_receive(:fetch).and_return(person)
+ Webfinger.should_receive(:new).and_return(wf_prof_mock)
+ Reshare.from_xml(@xml)
+ end
+ end
+ end
+ end
end