From 4d7a6064799ef54b7b5b681f00cd2c703f8709ab Mon Sep 17 00:00:00 2001 From: shibao Date: Wed, 16 Feb 2022 21:07:37 -0500 Subject: [PATCH] pass user registration controller test --- .../user_registration_controller_test.exs | 21 +++++++++++-------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/test/cannery_web/controllers/user_registration_controller_test.exs b/test/cannery_web/controllers/user_registration_controller_test.exs index 328fa73..0ffd352 100644 --- a/test/cannery_web/controllers/user_registration_controller_test.exs +++ b/test/cannery_web/controllers/user_registration_controller_test.exs @@ -1,15 +1,19 @@ defmodule CanneryWeb.UserRegistrationControllerTest do - use CanneryWeb.ConnCase, async: true + @moduledoc """ + Tests user registration + """ - import Cannery.AccountsFixtures + use CanneryWeb.ConnCase, async: true + import CanneryWeb.Gettext + + @moduletag :user_registration_controller_test describe "GET /users/register" do test "renders registration page", %{conn: conn} do conn = get(conn, Routes.user_registration_path(conn, :new)) response = html_response(conn, 200) - assert response =~ "

Register

" - assert response =~ "Log in" - assert response =~ "Register" + assert response =~ dgettext("actions", "Register") + assert response =~ dgettext("actions", "Log in") end test "redirects if already logged in", %{conn: conn} do @@ -28,15 +32,14 @@ defmodule CanneryWeb.UserRegistrationControllerTest do "user" => valid_user_attributes(email: email) }) - assert get_session(conn, :user_token) + assert get_session(conn, :phoenix_flash) == %{"info" => dgettext("prompts", "Please check your email to verify your account")} assert redirected_to(conn) =~ "/" # Now do a logged in request and assert on the menu conn = get(conn, "/") response = html_response(conn, 200) + # user's email is recorded as admin assert response =~ email - assert response =~ "Settings" - assert response =~ "Log out" end test "render errors for invalid data", %{conn: conn} do @@ -46,7 +49,7 @@ defmodule CanneryWeb.UserRegistrationControllerTest do }) response = html_response(conn, 200) - assert response =~ "

Register

" + assert response =~ gettext("Register") assert response =~ "must have the @ sign and no spaces" assert response =~ "should be at least 12 character" end