Use _path in all cases where we are not potentially changing the domain

This commit is contained in:
David Heinemeier Hansson
2025-04-13 08:17:36 +02:00
parent 7b60748796
commit dbf61f4fc3
28 changed files with 82 additions and 82 deletions
+9 -9
View File
@@ -5,34 +5,34 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
DISALLOWED_BROWSER = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0"
test "new" do
get new_session_url
get new_session_path
assert_response :success
end
test "new enforces browser compatibility" do
get new_session_url, env: { "HTTP_USER_AGENT" => DISALLOWED_BROWSER }
get new_session_path, env: { "HTTP_USER_AGENT" => DISALLOWED_BROWSER }
assert_select "svg", message: /Your browser is not supported/
get new_session_url, env: { "HTTP_USER_AGENT" => ALLOWED_BROWSER }
get new_session_path, env: { "HTTP_USER_AGENT" => ALLOWED_BROWSER }
assert_select "svg", text: /Your browser is not supported/, count: 0
end
test "create with valid credentials" do
post session_url, params: { email_address: "david@37signals.com", password: "secret123456" }
assert_redirected_to root_url
post session_path, params: { email_address: "david@37signals.com", password: "secret123456" }
assert_redirected_to root_path
assert cookies[:session_token].present?
end
test "create with invalid credentials" do
post session_url, params: { email_address: "david@37signals.com", password: "wrong" }
assert_redirected_to new_session_url
post session_path, params: { email_address: "david@37signals.com", password: "wrong" }
assert_redirected_to new_session_path
assert_not cookies[:session_token].present?
end
test "destroy" do
sign_in_as :kevin
delete session_url
assert_redirected_to new_session_url
delete session_path
assert_redirected_to new_session_path
assert_not cookies[:session_token].present?
end
end