Error rescue in parser now is specific to not a real type error
This commit is contained in:
parent
d130b82e42
commit
62e6ea0756
3 changed files with 13 additions and 7 deletions
|
|
@ -22,7 +22,8 @@ module Diaspora
|
|||
body.children.each do |post|
|
||||
begin
|
||||
object = post.name.camelize.constantize.from_xml post.to_s
|
||||
if object.respond_to? :person
|
||||
if object.is_a? Retraction
|
||||
elsif object.respond_to? :person
|
||||
object.person = parse_owner_from_xml post.to_s
|
||||
elsif object.is_a? Profile
|
||||
puts "got into parse objects from xml PROFILE"
|
||||
|
|
@ -31,8 +32,12 @@ module Diaspora
|
|||
person.save
|
||||
end
|
||||
objects << object
|
||||
rescue
|
||||
rescue NameError => e
|
||||
if e.message.include? 'wrong constant name'
|
||||
Rails.logger.info "Not a real type: #{object.to_s}"
|
||||
else
|
||||
raise e
|
||||
end
|
||||
end
|
||||
end
|
||||
objects
|
||||
|
|
@ -43,6 +48,7 @@ module Diaspora
|
|||
objects.each do |p|
|
||||
Rails.logger.info("Receiving object:\n#{p.inspect}")
|
||||
if p.is_a? Retraction
|
||||
puts "Got a retraction for #{p.post_id}"
|
||||
p.perform
|
||||
elsif p.is_a? Request
|
||||
User.owner.receive_friend_request(p)
|
||||
|
|
|
|||
|
|
@ -105,6 +105,7 @@ describe Diaspora::Parser do
|
|||
message = Factory.create(:status_message, :person => person)
|
||||
retraction = Retraction.for(message)
|
||||
request = Post.build_xml_for( [retraction] )
|
||||
puts request
|
||||
|
||||
StatusMessage.count.should == 1
|
||||
store_objects_from_xml( request )
|
||||
|
|
|
|||
|
|
@ -1,23 +1,22 @@
|
|||
require File.dirname(__FILE__) + '/../spec_helper'
|
||||
|
||||
describe Retraction do
|
||||
describe "posts" do
|
||||
before do
|
||||
@user = Factory.create(:user)
|
||||
@post = Factory.create(:status_message, :person => @user)
|
||||
end
|
||||
|
||||
describe 'serialization' do
|
||||
it 'should have a post id after serialization' do
|
||||
retraction = Retraction.for(@post)
|
||||
xml = retraction.to_xml.to_s
|
||||
xml.include?(@post.id.to_s).should == true
|
||||
end
|
||||
|
||||
end
|
||||
describe 'dispatching' do
|
||||
it 'should dispatch a message on delete' do
|
||||
Factory.create(:person)
|
||||
Post.send(:class_variable_get, :@@queue).should_receive(:add_post_request)
|
||||
@post.destroy
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue