Skip to content

Commit

Permalink
Merge branch 'hotfix/v0.1.0.1'
Browse files Browse the repository at this point in the history
  • Loading branch information
Dennis Schubert committed May 20, 2013
2 parents c63bcd5 + 1661615 commit fe9485d
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 5 deletions.
5 changes: 5 additions & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 8 additions & 3 deletions app/models/location.rb
Original file line number Diff line number Diff line change
@@ -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
2 changes: 1 addition & 1 deletion app/models/reshare.rb
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ def absolute_root
end

def address
absolute_root.location.try(:address)
absolute_root.try(:location).try(:address)
end

private
Expand Down
1 change: 1 addition & 0 deletions app/models/status_message.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion config/defaults.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/"
Expand Down
23 changes: 23 additions & 0 deletions spec/models/status_message_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,29 @@
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
Expand Down

0 comments on commit fe9485d

Please sign in to comment.