require "simplecov"
SimpleCov.start "rails"

ENV["RAILS_ENV"] ||= "test"
require_relative "../config/environment"
require "rails/test_help"

module ActiveSupport
  class TestCase
    # Run tests serially to avoid sqlite/FTS5 conflicts in test setup.
    parallelize(workers: 1)

    # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
    fixtures :all

    # Add more helper methods to be used by all tests here...
  end
end

module ActionDispatch
  class IntegrationTest
    # Helper method to login as a user in integration tests
    def login_as(user, password: "password123456")
      post login_path, params: {
        email: user.email,
        password: password
      }
    end

    # Helper method to logout
    def logout
      delete logout_path
    end
  end
end
