Merge pull request #6429 from svbergerem/fix-location-post-preview

Fix post preview with location
This commit is contained in:
Jonne Haß 2015-09-27 11:36:41 +02:00
commit 600457a552
4 changed files with 34 additions and 1 deletions

View file

@ -61,6 +61,7 @@ With the port to Bootstrap 3, app/views/terms/default.haml has a new structure.
* Capitalize "Powered by diaspora" [#6254](https://github.com/diaspora/diaspora/pull/6254)
* Display username and avatar for NSFW posts in mobile view [#6245](https://github.com/diaspora/diaspora/6245)
* Prevent multiple comment boxes on mobile [#6363](https://github.com/diaspora/diaspora/pull/6363)
* Correctly display location in post preview [#6429](https://github.com/diaspora/diaspora/pull/6429)
## Features
* Support color themes [#6033](https://github.com/diaspora/diaspora/pull/6033)

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