Fix remaining 12 multi-line conn shadowing issues
Manually refactor multi-line conn = post/put(conn, ...) patterns across user_session, user_settings, and user_registration controller tests. Rename shadowed conn to response using pipeline operator. Also add plans/multi-line-conn-refactoring.md spec for future Elixir-based tooling to handle these patterns automatically.
This commit is contained in:
@@ -25,15 +25,16 @@ defmodule FirehoseWeb.UserRegistrationControllerTest do
|
||||
Application.put_env(:firehose, :allowed_registration_email, email)
|
||||
on_exit(fn -> Application.delete_env(:firehose, :allowed_registration_email) end)
|
||||
|
||||
conn =
|
||||
post(conn, ~p"/users/register", %{
|
||||
response =
|
||||
conn
|
||||
|> post(~p"/users/register", %{
|
||||
"user" => valid_user_attributes(email: email)
|
||||
})
|
||||
|
||||
refute get_session(conn, :user_token)
|
||||
assert redirected_to(conn) == ~p"/users/log-in"
|
||||
refute get_session(response, :user_token)
|
||||
assert redirected_to(response) == ~p"/users/log-in"
|
||||
|
||||
assert conn.assigns.flash["info"] =~
|
||||
assert response.assigns.flash["info"] =~
|
||||
~r/An email was sent to .*, please access it to confirm your account/
|
||||
end
|
||||
|
||||
@@ -41,12 +42,13 @@ defmodule FirehoseWeb.UserRegistrationControllerTest do
|
||||
Application.put_env(:firehose, :allowed_registration_email, "with spaces")
|
||||
on_exit(fn -> Application.delete_env(:firehose, :allowed_registration_email) end)
|
||||
|
||||
conn =
|
||||
post(conn, ~p"/users/register", %{
|
||||
response =
|
||||
conn
|
||||
|> post(~p"/users/register", %{
|
||||
"user" => %{"email" => "with spaces"}
|
||||
})
|
||||
|> html_response(200)
|
||||
|
||||
response = html_response(conn, 200)
|
||||
assert response =~ "Register"
|
||||
assert response =~ "must have the @ sign and no spaces"
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user