This commit is contained in:
16
test/test_helpers/session_test_helper.rb
Normal file
16
test/test_helpers/session_test_helper.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
module SessionTestHelper
|
||||
def parsed_cookies
|
||||
ActionDispatch::Cookies::CookieJar.build(request, cookies.to_hash)
|
||||
end
|
||||
|
||||
def sign_in(user)
|
||||
user = users(user) unless user.is_a? User
|
||||
post session_url, params: { email_address: user.email_address, password: "secret123456" }
|
||||
assert cookies[:session_token].present?
|
||||
end
|
||||
|
||||
def sign_out
|
||||
delete session_url
|
||||
assert_not cookies[:session_token].present?
|
||||
end
|
||||
end
|
||||
20
test/test_helpers/system_test_helper.rb
Normal file
20
test/test_helpers/system_test_helper.rb
Normal file
@@ -0,0 +1,20 @@
|
||||
module SystemTestHelper
|
||||
include ActionView::Helpers::JavaScriptHelper
|
||||
|
||||
def sign_in(email_address, password = "secret123456")
|
||||
visit new_session_url
|
||||
|
||||
fill_in "email_address", with: email_address
|
||||
fill_in "password", with: password
|
||||
|
||||
click_on "log_in"
|
||||
assert_selector "h2", text: "Handbook"
|
||||
end
|
||||
|
||||
def fill_house_editor(name, content)
|
||||
execute_script <<~JS
|
||||
const editor = document.querySelector("[name='#{name}']")
|
||||
editor.value = "#{escape_javascript(content)}"
|
||||
JS
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user