diff --git a/app/assets/javascripts/app/views/content_view.js b/app/assets/javascripts/app/views/content_view.js
index 20ddadb0d..d462dd067 100644
--- a/app/assets/javascripts/app/views/content_view.js
+++ b/app/assets/javascripts/app/views/content_view.js
@@ -39,8 +39,8 @@ app.views.Content = app.views.Base.extend({
},
location: function(){
- var address = this.model.get('address')? this.model.get('address') : '';
- return address;
+ var location = this.model.get("location")? this.model.get("location") : "";
+ return location;
},
collapseOversized : function() {
diff --git a/app/assets/javascripts/app/views/location_map.js b/app/assets/javascripts/app/views/location_map.js
index e499e2371..59949ae16 100644
--- a/app/assets/javascripts/app/views/location_map.js
+++ b/app/assets/javascripts/app/views/location_map.js
@@ -4,12 +4,12 @@ app.views.LocationMap = app.views.Content.extend({
templateName: "status-message-map",
map: function() {
- var coordinates = this.model.get("coordinates");
+ var location = this.model.get("location");
// if (coordinates != "" && tileserver.enable) { // for when the tileserver is set via the diaspora.yml
- if (coordinates.lat) {
+ if (location.lat) {
var tileLayerSource = "https://api.tiles.mapbox.com/v4/{id}/{z}/{x}/{y}.png?access_token={accessToken}";
- var map = L.map("map").setView([coordinates.lat, coordinates.lng], 16);
+ var map = L.map("map").setView([location.lat, location.lng], 16);
var attribution = "Map data © OpenStreetMap contributors, " +
"CC-BY-SA, " +
"Imagery © Mapbox";
@@ -21,7 +21,7 @@ app.views.LocationMap = app.views.Content.extend({
accessToken: "pk.eyJ1IjoiemF6aWVtbyIsImEiOiI3ODVjMzVjNmM2ZTU3YWM3YTE5YWYwMTRhODljM2M1MSJ9.-nVgyS4PLnV4m9YkvMB5wA"
}).addTo(map);
- var markerOnMap = L.marker(coordinates).addTo(map);
+ var markerOnMap = L.marker(location).addTo(map);
return map;
}
diff --git a/app/assets/templates/status-message-location_tpl.jst.hbs b/app/assets/templates/status-message-location_tpl.jst.hbs
index 0d648125c..0f97e3d7a 100644
--- a/app/assets/templates/status-message-location_tpl.jst.hbs
+++ b/app/assets/templates/status-message-location_tpl.jst.hbs
@@ -1,5 +1,5 @@
-{{#if location}}
+{{#if location.address}}
{{/if}}
diff --git a/app/assets/templates/status-message-map_tpl.jst.hbs b/app/assets/templates/status-message-map_tpl.jst.hbs
index 87207d39c..6b344c792 100644
--- a/app/assets/templates/status-message-map_tpl.jst.hbs
+++ b/app/assets/templates/status-message-map_tpl.jst.hbs
@@ -1,4 +1,4 @@
-{{#if location}}
+{{#if location.lat}}
{{/if}}
diff --git a/app/models/reshare.rb b/app/models/reshare.rb
index f3cbdb2ed..456d12866 100644
--- a/app/models/reshare.rb
+++ b/app/models/reshare.rb
@@ -44,12 +44,12 @@ class Reshare < Post
absolute_root.try(:photos) || super
end
- def address
- absolute_root.try(:location).try(:address)
- end
-
- def coordinates
- {lat: absolute_root.try(:location).try(:lat), lng: absolute_root.try(:location).try(:lng)}
+ def post_location
+ {
+ address: absolute_root.try(:location).try(:address),
+ lat: absolute_root.try(:location).try(:lat),
+ lng: absolute_root.try(:location).try(:lng)
+ }
end
def poll
diff --git a/app/models/status_message.rb b/app/models/status_message.rb
index b69a682d6..3e6605866 100644
--- a/app/models/status_message.rb
+++ b/app/models/status_message.rb
@@ -158,12 +158,12 @@ class StatusMessage < Post
self.open_graph_url = self.message.urls[0]
end
- def address
- location.try(:address)
- end
-
- def coordinates
- {lat: location.try(:lat), lng: location.try(:lng)}
+ def post_location
+ {
+ address: location.try(:address),
+ lat: location.try(:lat),
+ lng: location.try(:lng)
+ }
end
protected
diff --git a/config/.jshint.json b/config/.jshint.json
index 15675a257..c56365620 100644
--- a/config/.jshint.json
+++ b/config/.jshint.json
@@ -53,7 +53,7 @@
"punycode",
"qq",
"blueimp",
-
+ "L",
"loginAs",
"logout",
"spec",
diff --git a/spec/models/reshare_spec.rb b/spec/models/reshare_spec.rb
index 3661bae94..0e13aacd4 100644
--- a/spec/models/reshare_spec.rb
+++ b/spec/models/reshare_spec.rb
@@ -291,23 +291,24 @@ describe Reshare, type: :model do
end
end
- describe ".coordinates" do
+ describe "#post_location" do
let(:status_message) { build(:status_message, text: "This is a status_message", author: bob.person, public: true) }
let(:reshare) { create(:reshare, root: status_message) }
context "with location" do
let(:location) { build(:location) }
- it "should deliver coordinates" do
+ it "should deliver address and coordinates" do
status_message.location = location
- expect(reshare.coordinates).to include(lat: location.lat, lng: location.lng)
+ expect(reshare.post_location).to include(address: location.address, lat: location.lat, lng: location.lng)
end
end
context "without location" do
- it "should deliver empty coordinates" do
- expect(reshare.coordinates[:lat]).to be_nil
- expect(reshare.coordinates[:lng]).to be_nil
+ it "should deliver empty address and coordinates" do
+ expect(reshare.post_location[:address]).to be_nil
+ expect(reshare.post_location[:lat]).to be_nil
+ expect(reshare.post_location[:lng]).to be_nil
end
end
end
diff --git a/spec/models/status_message_spec.rb b/spec/models/status_message_spec.rb
index 6b1523bce..d17a103fa 100644
--- a/spec/models/status_message_spec.rb
+++ b/spec/models/status_message_spec.rb
@@ -444,22 +444,23 @@ describe StatusMessage, type: :model do
end
end
- describe ".coordinates" do
+ describe "#coordinates" do
let(:status_message) { build(:status_message, text: @message_text) }
context "with location" do
let(:location) { build(:location) }
- it "should deliver coordinates" do
+ it "should deliver address and coordinates" do
status_message.location = location
- expect(status_message.coordinates).to include(lat: location.lat, lng: location.lng)
+ expect(status_message.post_location).to include(address: location.address, lat: location.lat, lng: location.lng)
end
end
context "without location" do
- it "should deliver empty coordinates" do
- expect(status_message.coordinates[:lat]).to be_nil
- expect(status_message.coordinates[:lng]).to be_nil
+ it "should deliver empty address and coordinates" do
+ expect(status_message.post_location[:address]).to be_nil
+ expect(status_message.post_location[:lat]).to be_nil
+ expect(status_message.post_location[:lng]).to be_nil
end
end
end