2023-08-15 13:50:39 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "application_system_test_case"
|
|
|
|
|
|
|
|
class SessionsTest < ApplicationSystemTestCase
|
|
|
|
test "can log in and log out existing user" do
|
2023-08-19 14:38:38 +00:00
|
|
|
user = users(:user)
|
2023-08-15 13:50:39 +00:00
|
|
|
visit new_session_path
|
2023-08-19 14:38:38 +00:00
|
|
|
fill_in "username", with: user.username
|
2023-08-15 13:50:39 +00:00
|
|
|
fill_in "password", with: "tolkien-abercrombie-hobb-barker"
|
2023-09-17 13:59:06 +00:00
|
|
|
click_button I18n.t("layouts.application.log_in")
|
2023-08-15 13:50:39 +00:00
|
|
|
assert_text I18n.t("sessions.logged_in")
|
2023-09-17 13:59:06 +00:00
|
|
|
click_link I18n.t("layouts.application.log_out")
|
2023-08-15 13:50:39 +00:00
|
|
|
assert_text I18n.t("sessions.logged_out")
|
|
|
|
end
|
2023-08-19 14:38:38 +00:00
|
|
|
|
|
|
|
test "cannot log in as an unconfirmed user" do
|
|
|
|
user = users(:unconfirmed_user)
|
|
|
|
visit new_session_path
|
|
|
|
fill_in "username", with: user.username
|
|
|
|
fill_in "password", with: "tolkien-abercrombie-hobb-barker"
|
2023-09-17 13:59:06 +00:00
|
|
|
click_button I18n.t("layouts.application.log_in")
|
2023-08-19 14:38:38 +00:00
|
|
|
assert_text I18n.t("sessions.account_not_confirmed")
|
|
|
|
end
|
2023-08-15 13:50:39 +00:00
|
|
|
end
|