L.marker([params.mlat, params.mlon]).addTo(map);
}
- $("#homeanchor").on("click", function (e) {
- e.preventDefault();
-
- var data = $(this).data(),
- center = L.latLng(data.lat, data.lon);
-
- map.setView(center, data.zoom);
- L.marker(center, { icon: OSM.getUserIcon() }).addTo(map);
- });
-
function remoteEditHandler(bbox, object) {
var remoteEditHost = "http://127.0.0.1:8111",
osmHost = location.protocol + "//" + location.host,
<%= link_to t("users.show.my settings"), edit_account_path, :class => "dropdown-item" %>
<%= link_to t("users.show.my_preferences"), preferences_path, :class => "dropdown-item" %>
<div class="dropdown-divider"></div>
- <%= yield :greeting %>
+ <% if current_user.home_location? %>
+ <%= link_to t("layouts.home"), account_home_path, :class => "dropdown-item" %>
+ <% end %>
<%= link_to t("layouts.logout"), logout_path(:referer => request.fullpath), :method => "post", :class => "geolink dropdown-item" %>
</div>
</div>
<% content_for(:body_class) { "map-layout" } %>
-<% if current_user&.home_location? %>
- <% content_for :greeting do %>
- <%= link_to t("layouts.home"),
- "#",
- :id => "homeanchor",
- :class => "set_position dropdown-item",
- :data => { :lat => current_user.home_lat,
- :lon => current_user.home_lon,
- :zoom => 15 } %>
- <% end %>
-<% end %>
-
<% content_for :header do %>
<%= render :partial => "layouts/search", :locals => { :autofocus => false } %>
<% end %>
--- /dev/null
+require "application_system_test_case"
+
+class AccountHomeTest < ApplicationSystemTestCase
+ test "Go to Home Location works on map layout pages" do
+ user = create(:user, :display_name => "test user", :home_lat => 60, :home_lon => 30)
+ sign_in_as(user)
+
+ visit root_path
+ assert_no_selector "img.leaflet-marker-icon"
+
+ click_on "test user"
+ click_on "Go to Home Location"
+ all "img.leaflet-marker-icon", :count => 1 do |marker|
+ assert_equal "My home location", marker["title"]
+ end
+
+ click_on "OpenStreetMap logo"
+ assert_no_selector "img.leaflet-marker-icon"
+ end
+
+ test "Go to Home Location works on non-map layout pages" do
+ user = create(:user, :display_name => "test user", :home_lat => 60, :home_lon => 30)
+ sign_in_as(user)
+
+ visit about_path
+ assert_no_selector "img.leaflet-marker-icon"
+
+ click_on "test user"
+ click_on "Go to Home Location"
+ all "img.leaflet-marker-icon", :count => 1 do |marker|
+ assert_equal "My home location", marker["title"]
+ end
+
+ click_on "OpenStreetMap logo"
+ assert_no_selector "img.leaflet-marker-icon"
+ end
+
+ test "Go to Home Location is not available for users without home location" do
+ user = create(:user, :display_name => "test user")
+ sign_in_as(user)
+
+ visit root_path
+ assert_no_selector "img.leaflet-marker-icon"
+
+ click_on "test user"
+ assert_no_link "Go to Home Location"
+ end
+end