# Configure Rails Environment
ENV["RAILS_ENV"] = "test"

require_relative "../test/dummy/config/environment"
ActiveRecord::Migrator.migrations_paths = [File.expand_path("../test/dummy/db/migrate", __dir__)]
# Don't eager load, since that expects Action Mailbox tables to be present in database.
Rails.configuration.eager_load = false
require "rails/test_help"

require "capybara_extensions"
require "template_helpers"

Showcase.sample_renderer = proc { _1 } if ENV["ROUGE_ENABLED"] == "false"

# Load fixtures from the engine
if ActiveSupport::TestCase.respond_to?(:fixture_path=)
  ActiveSupport::TestCase.fixture_path = File.expand_path("fixtures", __dir__)
  ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
  ActiveSupport::TestCase.file_fixture_path = ActiveSupport::TestCase.fixture_path + "/files"
  ActiveSupport::TestCase.fixtures :all
end

class ActiveSupport::TestCase
  include TemplateHelpers
end

class Showcase::IntegrationTest < ActionDispatch::IntegrationTest
  include Showcase::Engine.routes.url_helpers
  setup { @routes = Showcase::Engine.routes }
end
