From e33f4e68a8ce3ba7a8dfb843d3d32014bf9d5939 Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Mon, 20 May 2013 21:05:34 +0200 Subject: [PATCH 1/3] Fix 500 caused by deleted reshares --- app/models/reshare.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/reshare.rb b/app/models/reshare.rb index 1815badb4..5b3c5341b 100644 --- a/app/models/reshare.rb +++ b/app/models/reshare.rb @@ -80,7 +80,7 @@ class Reshare < Post end def address - absolute_root.location.try(:address) + absolute_root.try(:location).try(:address) end private From 286e9480542aa8349fa05925980ad4f5a75f719c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonne=20Ha=C3=9F?= Date: Mon, 20 May 2013 18:44:19 +0200 Subject: [PATCH 2/3] federate location --- app/models/location.rb | 11 ++++++++--- app/models/status_message.rb | 1 + spec/models/status_message_spec.rb | 23 +++++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/app/models/location.rb b/app/models/location.rb index b3896c32e..a1fb30572 100644 --- a/app/models/location.rb +++ b/app/models/location.rb @@ -1,12 +1,17 @@ class Location < ActiveRecord::Base - - before_validation :split_coords, :on => :create + before_validation :split_coords, on: :create + validates_presence_of :lat, :lng attr_accessor :coordinates + include Diaspora::Federated::Base + xml_attr :address + xml_attr :lat + xml_attr :lng + belongs_to :status_message def split_coords - coordinates.present? ? (self.lat, self.lng = coordinates.split(',')) : false + self.lat, self.lng = coordinates.split(',') if coordinates.present? end end diff --git a/app/models/status_message.rb b/app/models/status_message.rb index c46c3e3d3..0c95ebc01 100644 --- a/app/models/status_message.rb +++ b/app/models/status_message.rb @@ -15,6 +15,7 @@ class StatusMessage < Post xml_name :status_message xml_attr :raw_message xml_attr :photos, :as => [Photo] + xml_attr :location, :as => Location has_many :photos, :dependent => :destroy, :foreign_key => :status_message_guid, :primary_key => :guid diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb index d51a7713b..b160ae294 100644 --- a/spec/models/status_message_spec.rb +++ b/spec/models/status_message_spec.rb @@ -329,6 +329,29 @@ STR end end end + + context 'with a location' do + before do + @message.location = Location.new(coordinates: "1, 2").tap(&:save) + @xml = @message.to_xml.to_s + end + + it 'serializes the location' do + @xml.should include "location" + @xml.should include "lat" + @xml.should include "lng" + end + + describe ".from_xml" do + before do + @marshalled = StatusMessage.from_xml(@xml) + end + + it 'marshals the location' do + @marshalled.location.should be_present + end + end + end end describe '#after_dispatch' do From 1661615fe658b292da25fcbb2f2d9a9af80fa31a Mon Sep 17 00:00:00 2001 From: Dennis Schubert Date: Mon, 20 May 2013 21:28:10 +0200 Subject: [PATCH 3/3] Changelog and version number for the hotfix --- Changelog.md | 5 +++++ config/defaults.yml | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/Changelog.md b/Changelog.md index aa0cf68db..ffa3e2d56 100644 --- a/Changelog.md +++ b/Changelog.md @@ -1,3 +1,8 @@ +# 0.1.0.1 + +* Regression fix: 500 for deleted reshares introduced by the locator +* Federate locations + # 0.1.0.0 ## Refactor diff --git a/config/defaults.yml b/config/defaults.yml index 1fab2c585..fd563e7ea 100644 --- a/config/defaults.yml +++ b/config/defaults.yml @@ -4,7 +4,7 @@ defaults: version: - number: "0.1.0.0" # Do not touch unless doing a release, do not backport the version number that's in master but keep develp to always say "head" + number: "0.1.0.1" # Do not touch unless doing a release, do not backport the version number that's in master but keep develp to always say "head" heroku: false environment: url: "http://localhost:3000/"