2024-12-29 17:12:54 +08:00
|
|
|
ENV["RAILS_ENV"] ||= "test"
|
|
|
|
require_relative "../config/environment"
|
|
|
|
require "rails/test_help"
|
2024-12-30 00:09:54 +08:00
|
|
|
require "minitest/reporters"
|
|
|
|
Minitest::Reporters.use!
|
2024-12-29 17:12:54 +08:00
|
|
|
|
|
|
|
module ActiveSupport
|
|
|
|
class TestCase
|
|
|
|
# Run tests in parallel with specified workers
|
|
|
|
parallelize(workers: :number_of_processors)
|
|
|
|
|
|
|
|
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
|
|
|
fixtures :all
|
2024-12-31 14:20:22 +08:00
|
|
|
include ApplicationHelper
|
2024-12-29 17:12:54 +08:00
|
|
|
|
2025-01-02 11:59:27 +08:00
|
|
|
def is_logged_in?
|
|
|
|
!session[:user_id].nil?
|
|
|
|
end
|
|
|
|
|
2025-01-02 17:49:06 +08:00
|
|
|
# def log_in_as(user)
|
|
|
|
# session[:user_id] = user.id
|
|
|
|
# end
|
|
|
|
end
|
|
|
|
|
|
|
|
class ActionDispatch::IntegrationTest
|
|
|
|
def log_in_as(user, password: 'password', remember_me: '1')
|
|
|
|
post login_path, params: { session: { email: user.email,
|
|
|
|
password: password,
|
|
|
|
remember_me: remember_me } }
|
|
|
|
end
|
2024-12-29 17:12:54 +08:00
|
|
|
end
|
|
|
|
end
|