diff --git a/Changelog.md b/Changelog.md index 1da34110e..dbc248351 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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 diff --git a/app/models/status_message.rb b/app/models/status_message.rb index 8b0f81c34..949db615e 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -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 diff --git a/config/environment.rb b/config/environment.rb index ad18fc67e..4731a494a 100644 --- a/config/environment.rb +++ b/config/environment.rb @@ -38,3 +38,7 @@ module Devise end end end + + +# Ensure Builder is loaded +require 'active_support/builder' unless defined?(Builder) diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index 14f3d7da2..d51a7713b 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -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 "I hate WALRUSES!" 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