mirror of
https://github.com/maybe-finance/maybe.git
synced 2025-07-19 13:19:39 +02:00
Use DB for auth sessions (#1233)
* DB sessions * Validations for profile image
This commit is contained in:
parent
82c298307d
commit
1ffa13f3b3
27 changed files with 118 additions and 76 deletions
|
@ -5,14 +5,30 @@ class SessionsControllerTest < ActionDispatch::IntegrationTest
|
|||
@user = users(:family_admin)
|
||||
end
|
||||
|
||||
test "can sign in" do
|
||||
post session_url, params: { email: @user.email, password: "password" }
|
||||
assert_redirected_to root_url
|
||||
test "login page" do
|
||||
get new_session_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "sets last_login_at on successful login" do
|
||||
assert_changes -> { @user.reload.last_login_at }, from: nil do
|
||||
post session_url, params: { email: @user.email, password: "password" }
|
||||
end
|
||||
test "can sign in" do
|
||||
sign_in @user
|
||||
assert_redirected_to root_url
|
||||
|
||||
get root_url
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "fails to sign in with bad password" do
|
||||
post sessions_url, params: { email: @user.email, password: "bad" }
|
||||
assert_response :unprocessable_entity
|
||||
assert_equal "Invalid email or password.", flash[:alert]
|
||||
end
|
||||
|
||||
test "can sign out" do
|
||||
sign_in @user
|
||||
|
||||
delete session_url(@user.sessions.order(:created_at).last)
|
||||
assert_redirected_to root_url
|
||||
assert_equal "You have signed out successfully.", flash[:notice]
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue