First crack
This commit is contained in:
33
test/controllers/sessions_controller_test.rb
Normal file
33
test/controllers/sessions_controller_test.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
require "test_helper"
|
||||
|
||||
class SessionsControllerTest < ActionDispatch::IntegrationTest
|
||||
setup { @user = User.take }
|
||||
|
||||
test "new" do
|
||||
get new_session_path
|
||||
assert_response :success
|
||||
end
|
||||
|
||||
test "create with valid credentials" do
|
||||
post session_path, params: { email_address: @user.email_address, password: "password" }
|
||||
|
||||
assert_redirected_to root_path
|
||||
assert cookies[:session_id]
|
||||
end
|
||||
|
||||
test "create with invalid credentials" do
|
||||
post session_path, params: { email_address: @user.email_address, password: "wrong" }
|
||||
|
||||
assert_redirected_to new_session_path
|
||||
assert_nil cookies[:session_id]
|
||||
end
|
||||
|
||||
test "destroy" do
|
||||
sign_in_as(User.take)
|
||||
|
||||
delete session_path
|
||||
|
||||
assert_redirected_to new_session_path
|
||||
assert_empty cookies[:session_id]
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user