fixed reshare specs; all specs green
This commit is contained in:
parent
a8400ad460
commit
987d44c41c
2 changed files with 30 additions and 3 deletions
|
|
@ -45,7 +45,13 @@ class Reshare < Post
|
|||
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
|
||||
|
||||
if root_author.diaspora_handle != post.diaspora_handle
|
||||
raise "Diaspora ID (#{post.diaspora_handle}) in the root does not match the Diaspora ID (#{root_author.diaspora_handle}) specified in the reshare!"
|
||||
end
|
||||
|
||||
post.author_id = root_author.id
|
||||
post.save!
|
||||
end
|
||||
|
||||
self.root_id = post.id
|
||||
|
|
|
|||
|
|
@ -75,7 +75,8 @@ describe Reshare do
|
|||
|
||||
context 'remote' do
|
||||
before do
|
||||
@root_object = @reshare.root.delete
|
||||
@root_object = @reshare.root
|
||||
@root_object.delete
|
||||
end
|
||||
|
||||
it 'fetches the root author from root_diaspora_id' do
|
||||
|
|
@ -84,6 +85,8 @@ describe Reshare do
|
|||
@original_author = @reshare.root.author.dup
|
||||
@reshare.root.author.delete
|
||||
|
||||
@original_author.profile = @original_profile
|
||||
|
||||
wf_prof_mock = mock
|
||||
wf_prof_mock.should_receive(:fetch).and_return(@original_author)
|
||||
Webfinger.should_receive(:new).and_return(wf_prof_mock)
|
||||
|
|
@ -99,7 +102,7 @@ describe Reshare 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)
|
||||
Faraday.default_connection.stub(: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
|
||||
|
|
@ -115,8 +118,26 @@ describe Reshare do
|
|||
end
|
||||
|
||||
it 'correctly sets the author' do
|
||||
@original_author = @reshare.root.author
|
||||
Reshare.from_xml(@xml).root.reload.author.reload.should == @original_author
|
||||
end
|
||||
|
||||
it 'verifies that the author of the post received is the same as the author in the reshare xml' do
|
||||
@original_author = @reshare.root.author.dup
|
||||
@xml = @reshare.to_xml.to_s
|
||||
|
||||
different_person = Factory.create(:person)
|
||||
|
||||
wf_prof_mock = mock
|
||||
wf_prof_mock.should_receive(:fetch).and_return(different_person)
|
||||
Webfinger.should_receive(:new).and_return(wf_prof_mock)
|
||||
|
||||
different_person.stub(:url).and_return(@original_author.url)
|
||||
|
||||
lambda{
|
||||
Reshare.from_xml(@xml)
|
||||
}.should raise_error /^Diaspora ID \(.+\) in the root does not match the Diaspora ID \(.+\) specified in the reshare!$/
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue