Merge pull request #3940 from MrZYX/embed_photo_xml

Embed associated photos into the status message xml
This commit is contained in:
Florian Staudacher 2013-04-21 13:32:26 -07:00
commit 3cb6f1cc3f
4 changed files with 30 additions and 1 deletions

View file

@ -105,6 +105,7 @@ everything is set up.
* Load images via sprites [#4039](https://github.com/diaspora/diaspora/pull/4039)
* Delete unnecessary javascript views. [#4059](https://github.com/diaspora/diaspora/pull/4059)
* Cleanup of script/server
* Attempt to stabilize federation of attached photos (fix [#3033](https://github.com/diaspora/diaspora/issues/3033) [#3940](https://github.com/diaspora/diaspora/pull/3940)
## Bug fixes

View file

@ -14,6 +14,7 @@ class StatusMessage < Post
validates_length_of :text, :maximum => 65535, :message => I18n.t('status_messages.too_long', :count => 65535)
xml_name :status_message
xml_attr :raw_message
xml_attr :photos, :as => [Photo]
has_many :photos, :dependent => :destroy, :foreign_key => :status_message_guid, :primary_key => :guid

View file

@ -38,3 +38,7 @@ module Devise
end
end
end
# Ensure Builder is loaded
require 'active_support/builder' unless defined?(Builder)

View file

@ -280,7 +280,7 @@ STR
@message.text = text
@message.to_xml.to_s.should include Builder::XChar.encode(text)
end
it 'serializes the message' do
@xml.should include "<raw_message>I hate WALRUSES!</raw_message>"
end
@ -306,6 +306,29 @@ STR
@marshalled.diaspora_handle.should == @message.diaspora_handle
end
end
context 'with some photos' do
before do
@message.photos << FactoryGirl.build(:photo)
@message.photos << FactoryGirl.build(:photo)
@xml = @message.to_xml.to_s
end
it 'serializes the photos' do
@xml.should include "photo"
@xml.should include @message.photos.first.remote_photo_path
end
describe '.from_xml' do
before do
@marshalled = StatusMessage.from_xml(@xml)
end
it 'marshals the photos' do
@marshalled.photos.size.should == 2
end
end
end
end
describe '#after_dispatch' do