Merge branch 'master' of github.com:diaspora/diaspora
This commit is contained in:
commit
bb3442afa5
2 changed files with 42 additions and 8 deletions
|
|
@ -4,11 +4,6 @@
|
|||
|
||||
module Diaspora
|
||||
|
||||
def self.bone(user)
|
||||
exporter = Diaspora::Exporter.new(Diaspora::Exporters::XML)
|
||||
exporter.execute(user)
|
||||
end
|
||||
|
||||
class Exporter
|
||||
def initialize(strategy)
|
||||
self.class.send(:include, strategy)
|
||||
|
|
@ -22,7 +17,7 @@ module Diaspora
|
|||
xml.user {
|
||||
xml.username user.username
|
||||
xml.serialized_private_key user.serialized_private_key
|
||||
xml.person user.person.to_xml
|
||||
xml.parent << user.person.to_xml
|
||||
|
||||
xml.aspects {
|
||||
user.aspects.each do |aspect|
|
||||
|
|
@ -36,8 +31,14 @@ module Diaspora
|
|||
end
|
||||
}
|
||||
xml.posts {
|
||||
aspect.posts.each do |post|
|
||||
xml.post post.to_xml if post.respond_to? :to_xml
|
||||
aspect.posts.find_all_by_person_id(user.person.id).each do |post|
|
||||
post_doc = post.to_xml
|
||||
|
||||
post.comments.each do |comment|
|
||||
post_doc << comment.to_xml
|
||||
end
|
||||
|
||||
xml.post post_doc
|
||||
end
|
||||
}
|
||||
}
|
||||
|
|
|
|||
33
spec/lib/exporter_spec.rb
Normal file
33
spec/lib/exporter_spec.rb
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
# Copyright (c) 2010, Diaspora Inc. This file is
|
||||
# licensed under the Affero General Public License version 3. See
|
||||
# the COPYRIGHT file.
|
||||
|
||||
require 'spec_helper'
|
||||
require File.dirname(__FILE__) + '/../../lib/diaspora/exporter'
|
||||
|
||||
describe Diaspora::Exporter do
|
||||
|
||||
let!(:user1) { Factory(:user) }
|
||||
let!(:user2) { Factory(:user) }
|
||||
|
||||
let(:aspect1) { user1.aspect(:name => "Work") }
|
||||
let(:aspect2) { user2.aspect(:name => "Family") }
|
||||
|
||||
let!(:status_message1) { user1.post(:status_message, :message => "One", :public => true, :to => aspect1.id) }
|
||||
let!(:status_message2) { user1.post(:status_message, :message => "Two", :public => true, :to => aspect1.id) }
|
||||
let!(:status_message3) { user2.post(:status_message, :message => "Three", :public => false, :to => aspect2.id) }
|
||||
|
||||
let!(:exported) { Diaspora::Exporter.new(Diaspora::Exporters::XML).execute(user1) }
|
||||
|
||||
it 'should include a users posts' do
|
||||
exported.should include status_message1.to_xml.to_s
|
||||
exported.should include status_message2.to_xml.to_s
|
||||
exported.should_not include status_message3.to_xml.to_s
|
||||
end
|
||||
|
||||
it 'should include a users private key' do
|
||||
exported.should include user1.serialized_private_key
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
Loading…
Reference in a new issue