- Update session creation to use safe navigation operator - Implement log_out method in SessionsHelper - Add session reset and login on user creation - Improve user login tests for better coverage These changes improve the user session management by ensuring that the session is handled more safely and efficiently. The addition of the log_out method centralizes session termination, while the updated tests ensure that both login and logout functionality are thoroughly validated.
31 lines
1.0 KiB
Ruby
31 lines
1.0 KiB
Ruby
require "test_helper"
|
|
|
|
class UsersSignupTest < ActionDispatch::IntegrationTest
|
|
test "invalid signup information" do
|
|
get signup_path
|
|
assert_no_difference 'User.count' do
|
|
post users_path, params: { user: { name: "",
|
|
email: "user@invalid",
|
|
password: "foo",
|
|
password_confirmation: "bar" } }
|
|
end
|
|
assert_template 'users/new'
|
|
assert_select 'div#error_explanation'
|
|
assert_select 'div.alert-danger'
|
|
end
|
|
|
|
test "valid signup information" do
|
|
get signup_path
|
|
assert_difference 'User.count', 1 do
|
|
post users_path, params: { user: {name: "Example User",
|
|
email: "user@example.com",
|
|
password: "password",
|
|
password_confirmation: "password" } }
|
|
end
|
|
follow_redirect!
|
|
assert_template 'users/show'
|
|
assert_not flash.notice
|
|
assert is_logged_in?
|
|
end
|
|
end
|