]> git.openstreetmap.org Git - rails.git/blob - test/system/account_home_test.rb
Show alert on account home page if home location is not set
[rails.git] / test / system / account_home_test.rb
1 require "application_system_test_case"
2
3 class AccountHomeTest < ApplicationSystemTestCase
4   test "Go to Home Location works on map layout pages" do
5     user = create(:user, :display_name => "test user", :home_lat => 60, :home_lon => 30)
6     sign_in_as(user)
7
8     visit root_path
9     assert_no_selector "img.leaflet-marker-icon"
10
11     click_on "test user"
12     click_on "Go to Home Location"
13     all "img.leaflet-marker-icon", :count => 1 do |marker|
14       assert_equal "My home location", marker["title"]
15     end
16
17     click_on "OpenStreetMap logo"
18     assert_no_selector "img.leaflet-marker-icon"
19   end
20
21   test "Go to Home Location works on non-map layout pages" do
22     user = create(:user, :display_name => "test user", :home_lat => 60, :home_lon => 30)
23     sign_in_as(user)
24
25     visit about_path
26     assert_no_selector "img.leaflet-marker-icon"
27
28     click_on "test user"
29     click_on "Go to Home Location"
30     all "img.leaflet-marker-icon", :count => 1 do |marker|
31       assert_equal "My home location", marker["title"]
32     end
33
34     click_on "OpenStreetMap logo"
35     assert_no_selector "img.leaflet-marker-icon"
36   end
37
38   test "Go to Home Location is not available for users without home location" do
39     user = create(:user, :display_name => "test user")
40     sign_in_as(user)
41
42     visit root_path
43     assert_no_selector "img.leaflet-marker-icon"
44
45     click_on "test user"
46     assert_no_link "Go to Home Location"
47   end
48
49   test "account home page shows a warning when visited by users without home location" do
50     user = create(:user, :display_name => "test user")
51     sign_in_as(user)
52
53     visit account_home_path
54     assert_no_selector "img.leaflet-marker-icon"
55     assert_text "Home location is not set"
56   end
57 end