diff --git a/lib/diaspora/exporter.rb b/lib/diaspora/exporter.rb index 589cacfa9..5f40322fb 100644 --- a/lib/diaspora/exporter.rb +++ b/lib/diaspora/exporter.rb @@ -14,6 +14,7 @@ module Diaspora module XML def execute(user) builder = Nokogiri::XML::Builder.new do |xml| + user_person_id = user.person.id xml.export { xml.user { xml.username user.username @@ -33,7 +34,7 @@ module Diaspora } xml.post_ids { - aspect.posts.each do |post| + aspect.posts.find_all_by_person_id(user_person_id).each do |post| xml.post_id post.id end } @@ -48,7 +49,7 @@ module Diaspora } xml.posts { - user.raw_visible_posts.find_all_by_person_id(user.person.id).each do |post| + user.raw_visible_posts.find_all_by_person_id(user_person_id).each do |post| #post_doc = post.to_xml #post.comments.each do |comment| diff --git a/spec/lib/exporter_spec.rb b/spec/lib/exporter_spec.rb index b902f12d7..71e9e3f85 100644 --- a/spec/lib/exporter_spec.rb +++ b/spec/lib/exporter_spec.rb @@ -50,4 +50,11 @@ describe Diaspora::Exporter do doc = Nokogiri::XML::parse(exported) doc.xpath('/export/people').to_s.should include user3.person.id.to_s end + + it 'should serialize only a users posts within his aspects' do + message = Factory(:status_message, :message => "Shouldn't be here", :person => user3.person) + aspect1.posts << message + doc = Nokogiri::XML::parse(exported) + doc.xpath('/export/aspects').to_s.should_not include message.message + end end