ENV["RAILS_ENV"] ||= "test" require_relative "../config/environment" require "rails/test_help" module ActiveSupport class TestCase # Run tests in parallel with specified workers parallelize(workers: :number_of_processors) DOC_JSON = { version: 2, sheets: [ { id: "s1", name: "Blatt 1", objects: [] } ] }.to_json def create_user(email = "anna@example.com") = User.create!(email:) def create_document(owner, title: "Budget") = owner.owned_documents.create!(title:, content: DOC_JSON) end end module SignInHelper # signs in through the real code flow def sign_in(user) link = MagicLink.issue!(email: user.email) post "/api/auth/code", params: { email: user.email, code: link.code }, as: :json assert_response :success end def json = response.parsed_body end class ActionDispatch::IntegrationTest include SignInHelper end