Fix post preview with location

This commit is contained in:
Steffen van Bergerem 2015-09-26 10:14:18 +02:00
parent 9d6ce5b110
commit a5ca78bc87
3 changed files with 33 additions and 1 deletions

View file

@ -327,6 +327,17 @@ app.views.Publisher = Backbone.View.extend({
var mentionedPeople = this.getMentionedPeople(serializedForm);
var date = (new Date()).toISOString();
var poll = this.getPollData(serializedForm);
var locationCoords = serializedForm["location[coords]"];
if(!locationCoords || locationCoords === "") {
locationCoords = ["", ""];
} else {
locationCoords = locationCoords.split(",");
}
var location = {
"address": $("#location_address").val(),
"lat": locationCoords[0],
"lng": locationCoords[1]
};
var previewMessage = {
"id" : 0,
@ -340,7 +351,7 @@ app.views.Publisher = Backbone.View.extend({
"photos" : photos,
"frame_name" : "status",
"title" : serializedForm["status_message[text]"],
"address" : $("#location_address").val(),
"location" : location,
"interactions" : {"likes":[],"reshares":[],"comments_count":0,"likes_count":0,"reshares_count":0},
"poll": poll
};

View file

@ -85,3 +85,17 @@ Feature: preview posts in the stream
Then I should see a ".poll_form" within ".stream_element"
And I should see a "form" within ".stream_element"
And I close the publisher
Scenario: preview a post with location
Given I expand the publisher
When I fill in the following:
| status_message_fake_text | I am eating yogurt |
And I allow geolocation
And I click on selector "#locator"
When I fill in the following:
| status_message_fake_text | I am eating yogurt |
| location_address | Some cool place |
And I press "Preview"
Then I should see a ".near-from" within ".stream_element"
And I should see "Some cool place" within ".stream_element .near-from"
And I close the publisher

View file

@ -0,0 +1,7 @@
When /^I allow geolocation$/ do
page.execute_script <<-JS
navigator.geolocation.getCurrentPosition = function(success) {
success({coords: {latitude: 42.42424242, longitude: 3.14159}});
};
JS
end