1 # frozen_string_literal: true
6 class LocationsControllerTest < ActionDispatch::IntegrationTest
8 # test all routes which lead to this controller
11 { :path => "/profile/location", :method => :get },
12 { :controller => "profiles/locations", :action => "show" }
15 { :path => "/profile/location", :method => :put },
16 { :controller => "profiles/locations", :action => "update" }
24 get profile_location_path
26 assert_response :success
30 def test_show_unauthorized
31 get profile_location_path
33 assert_redirected_to login_path(:referer => profile_location_path)
40 put profile_location_path, :params => { :user => { :home_lat => 60, :home_lon => 30, :home_location_name => "Лисий Нос" } }
42 assert_redirected_to user_path(user)
44 assert_response :success
46 assert_dom ".alert-success", :text => "Profile location updated."
49 assert_equal 60, user.home_lat
50 assert_equal 30, user.home_lon
51 assert_equal "Лисий Нос", user.home_location_name
52 assert_equal 3543348019, user.home_tile
55 def test_update_lat_out_of_range
59 put profile_location_path, :params => { :user => { :home_lat => 91, :home_lon => 30, :home_location_name => "Лисий Нос" } }
61 assert_response :success
63 assert_dom ".alert-danger", :text => "Couldn't update profile location."
66 assert_nil user.home_lat
67 assert_nil user.home_lon
68 assert_nil user.home_location_name
69 assert_nil user.home_tile
72 def test_update_lon_out_of_range
76 put profile_location_path, :params => { :user => { :home_lat => 60, :home_lon => 181, :home_location_name => "Лисий Нос" } }
78 assert_response :success
80 assert_dom ".alert-danger", :text => "Couldn't update profile location."
83 assert_nil user.home_lat
84 assert_nil user.home_lon
85 assert_nil user.home_location_name
86 assert_nil user.home_tile