4 class LocationsControllerTest < ActionDispatch::IntegrationTest
6 # test all routes which lead to this controller
9 { :path => "/profile/location", :method => :get },
10 { :controller => "profiles/locations", :action => "show" }
13 { :path => "/profile/location", :method => :put },
14 { :controller => "profiles/locations", :action => "update" }
22 get profile_location_path
24 assert_response :success
28 def test_show_unauthorized
29 get profile_location_path
31 assert_redirected_to login_path(:referer => profile_location_path)
38 put profile_location_path, :params => { :user => { :home_lat => 60, :home_lon => 30, :home_location_name => "Лисий Нос" } }
40 assert_redirected_to user_path(user)
42 assert_response :success
44 assert_dom ".alert-success", :text => "Profile location updated."
47 assert_equal 60, user.home_lat
48 assert_equal 30, user.home_lon
49 assert_equal "Лисий Нос", user.home_location_name
50 assert_equal 3543348019, user.home_tile
53 def test_update_lat_out_of_range
57 put profile_location_path, :params => { :user => { :home_lat => 91, :home_lon => 30, :home_location_name => "Лисий Нос" } }
59 assert_response :success
61 assert_dom ".alert-danger", :text => "Couldn't update profile location."
64 assert_nil user.home_lat
65 assert_nil user.home_lon
66 assert_nil user.home_location_name
67 assert_nil user.home_tile
70 def test_update_lon_out_of_range
74 put profile_location_path, :params => { :user => { :home_lat => 60, :home_lon => 181, :home_location_name => "Лисий Нос" } }
76 assert_response :success
78 assert_dom ".alert-danger", :text => "Couldn't update profile location."
81 assert_nil user.home_lat
82 assert_nil user.home_lon
83 assert_nil user.home_location_name
84 assert_nil user.home_tile