diff --git a/app/assets/javascripts/app/views/publisher_view.js b/app/assets/javascripts/app/views/publisher_view.js index 625dfcbf0..4e128a572 100644 --- a/app/assets/javascripts/app/views/publisher_view.js +++ b/app/assets/javascripts/app/views/publisher_view.js @@ -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 }; diff --git a/features/desktop/post_preview.feature b/features/desktop/post_preview.feature index beb86a974..0cafd0077 100644 --- a/features/desktop/post_preview.feature +++ b/features/desktop/post_preview.feature @@ -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 diff --git a/features/step_definitions/location_steps.rb b/features/step_definitions/location_steps.rb new file mode 100644 index 000000000..5a37904c4 --- /dev/null +++ b/features/step_definitions/location_steps.rb @@ -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