Files

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

102 lines
4.5 KiB
Ruby
Raw Permalink Normal View History

2025-05-05 09:29:55 +02:00
# frozen_string_literal: true
#-- copyright
2020-01-15 11:31:26 +01:00
# OpenProject is an open source project management software.
# Copyright (C) the OpenProject GmbH
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
# Copyright (C) 2006-2013 Jean-Philippe Lang
# Copyright (C) 2010-2013 the ChiliProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
# See COPYRIGHT and LICENSE files for more details.
ENV["RAILS_ENV"] ||= "test"
2025-02-04 12:22:30 +01:00
require_relative "../config/environment"
require "factory_bot"
2018-05-07 15:12:08 +02:00
require "factory_bot_rails"
require "rspec/rails"
require "shoulda/matchers"
# Require test_prof helpers for better performance around factories/specs
# see https://test-prof.evilmartians.io for all options.
require "test_prof/recipes/rspec/before_all"
require "test_prof/recipes/rspec/let_it_be"
require "test_prof/recipes/rspec/factory_default"
# Encourages fixing factories as soon as possible
require "test_prof/factory_prof/nate_heckler"
2023-09-27 11:06:25 -05:00
# Allows sampling a random set of specs or example groups for profiling.
require "test_prof/recipes/rspec/sample"
2022-06-29 15:02:05 +02:00
# Add PaperTrail integration so that it is disabled by default
# https://github.com/paper-trail-gem/paper_trail#7b-rspec
require "paper_trail/frameworks/rspec"
# Requires supporting ruby files with custom matchers and macros, etc, in
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
# run as spec files by default. This means that files in spec/support that end
# in _spec.rb will both be required and run as specs, causing the specs to be
# run twice. It is recommended that you do not name files matching this glob to
# end with _spec.rb. You can configure this pattern with the --pattern
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
#
# The following line is provided for convenience purposes. It has the downside
# of increasing the boot-up time by auto-requiring all files in the support
# directory. Alternatively, in the individual `*_spec.rb` files, manually
# require only the support files necessary.
#
# The files are sorted before requiring them to ensure the load order is the same
# everywhere. There are certain helpers that depend on a expected order.
# The CI may load the files in a different order than what you see locally which
# may lead to broken specs on the CI, if we don't sort here
# (example: with_config.rb has to precede with_direct_uploads.rb).
#
2024-01-04 17:01:17 +01:00
require_relative "support/parallel_helper"
require_relative "support/download_list"
require_relative "support/capybara"
2026-02-25 11:05:33 +01:00
Rails.root.glob("spec/support/**/*.rb").each { |f| require_relative f }
Rails.root.glob("spec/features/support/**/*.rb").each { |f| require f }
Rails.root.glob("spec/lib/api/v3/support/**/*.rb").each { |f| require f }
Rails.root.glob("spec/requests/api/v3/support/**/*.rb").each { |f| require f }
# Checks for pending migration and applies them before tests are run.
# If you are not using ActiveRecord, you can remove this line.
ActiveRecord::Migration.maintain_test_schema! unless ENV["CI"]
2026-02-25 11:05:33 +01:00
ActiveRecord::Base.logger = ActiveSupport::Logger.new($stdout, level: :debug) if ENV["SQL_DEBUG_OUTPUT"]
RSpec.configure do |config|
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_paths = [Rails.root.join("spec/fixtures").to_s]
# Filter lines from Rails gems in backtraces.
config.filter_rails_from_backtrace!
# Add helpers to parse json-responses
config.include JsonSpec::Helpers
2019-10-11 12:55:34 +02:00
# Add job helper
2020-12-16 16:37:33 +01:00
# Only the ActiveJob::TestHelper is actually used but it in turn requires
# e.g. assert_nothing_raised
2023-01-13 14:28:59 +01:00
config.include ActiveSupport::Testing::Assertions
config.include ActiveJob::TestHelper
2019-10-11 12:55:34 +02:00
OpenProject::Configuration["attachments_storage_path"] = "tmp/files#{ENV.fetch('TEST_ENV_NUMBER', nil)}"
end