diff --git a/app/models/post.rb b/app/models/post.rb index 1458f4da9e0b106e4b123f3681c67771952dae08..1edded31bd75bddaaff340d2afc88fd1c13794e6 100644 --- a/app/models/post.rb +++ b/app/models/post.rb @@ -29,6 +29,9 @@ class Post < ActiveRecord::Base cattr_reader :per_page @@per_page = 10 + def diaspora_handle + read_attribute(:diaspora_handle) || self.author.diaspora_handle + end def user_refs if AspectVisibility.exists?(:post_id => self.id) self.post_visibilities.count + 1 diff --git a/spec/models/activity_streams/photo_spec.rb b/spec/models/activity_streams/photo_spec.rb index f334bc2e5a3b3f771984afffff9ec03cfdfdff1a..b48b17ed6fc725ac5156ae15907710efbf4ac5af 100644 --- a/spec/models/activity_streams/photo_spec.rb +++ b/spec/models/activity_streams/photo_spec.rb @@ -27,10 +27,16 @@ JSON end describe 'serialization' do + before do + @photo = Factory(:activity_streams_photo) + xml = @photo.to_diaspora_xml.to_s + @marshalled = Diaspora::Parser.from_xml(xml) + end it 'Diaspora::Parser should pick the right class' do - photo = Factory(:activity_streams_photo) - xml = photo.to_diaspora_xml.to_s - Diaspora::Parser.from_xml(xml).class.should == ActivityStreams::Photo + @marshalled.class.should == ActivityStreams::Photo + end + it 'marshals the author' do + @marshalled.author.should == @photo.author end end end