Check authentication on each request #26
2 changed files with 13 additions and 13 deletions
|
@ -4,4 +4,15 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase
|
||||||
driven_by :selenium,
|
driven_by :selenium,
|
||||||
using: ENV["VISIBLE_SYSTEM_TESTS"].present? ? :chrome : :headless_chrome,
|
using: ENV["VISIBLE_SYSTEM_TESTS"].present? ? :chrome : :headless_chrome,
|
||||||
screen_size: [ 1400, 1400 ]
|
screen_size: [ 1400, 1400 ]
|
||||||
|
|
||||||
|
def login(email, password = "secret")
|
||||||
|
visit new_session_url
|
||||||
|
|
||||||
|
fill_in "Email", with: email
|
||||||
|
fill_in "Password", with: "secret"
|
||||||
|
|
||||||
|
click_on "Create Session"
|
||||||
|
|
||||||
|
assert_text "Session was successfully created"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -6,24 +6,13 @@ class SessionsTest < ApplicationSystemTestCase
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should create session" do
|
test "should create session" do
|
||||||
visit new_session_url
|
login(@user.email)
|
||||||
|
|
||||||
fill_in "Email", with: @user.email
|
|
||||||
fill_in "Password", with: "secret"
|
|
||||||
|
|
||||||
click_on "Create Session"
|
|
||||||
|
|
||||||
assert_text "Session was successfully created"
|
assert_text "Session was successfully created"
|
||||||
end
|
end
|
||||||
|
|
||||||
test "should destroy Session" do
|
test "should destroy Session" do
|
||||||
visit new_session_url
|
login(@user.email)
|
||||||
|
|
||||||
fill_in "Email", with: @user.email
|
|
||||||
fill_in "Password", with: "secret"
|
|
||||||
|
|
||||||
click_on "Create Session"
|
|
||||||
assert_text "Session was successfully created"
|
|
||||||
|
|
||||||
visit root_url
|
visit root_url
|
||||||
click_on "Log out", match: :first
|
click_on "Log out", match: :first
|
||||||
|
|
Loading…
Reference in a new issue