Sha256: ce544ef998d341f1a0477e14f8557bd0a5785ae877962a94ac33dc8a6a19f6d6

Contents?: true

Size: 1.37 KB

Versions: 6

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require "bullet"

RSpec.configure do |config|
  Decidim::ApplicationJob.include(Bullet::ActiveJob) if defined?(Bullet::ActiveJob)

  Rails.application.config.after_initialize do
    Bullet.enable = Decidim::Env.new("DECIDIM_BULLET_ENABLED", "true").present?
    Bullet.rails_logger = true
    Bullet.raise = true
    Bullet.stacktrace_includes = %w(decidim-)

    # Detect N+1 queries
    Bullet.n_plus_one_query_enable = Decidim::Env.new("DECIDIM_BULLET_N_PLUS_ONE", "false").present?
    # Detect eager-loaded associations which are not used
    Bullet.unused_eager_loading_enable = Decidim::Env.new("DECIDIM_BULLET_UNUSED_EAGER", "false").present?
    # Detect unnecessary COUNT queries which could be avoided with a counter_cache
    Bullet.counter_cache_enable = Decidim::Env.new("DECIDIM_BULLET_COUNTER_CACHE", "true").present?

    # Having a counter cache for this column is too difficult, as this should also work for the Decidim::DummyResource
    # model, and counter_cache needs a real table in the database.
    Bullet.add_safelist type: :counter_cache, class_name: "Decidim::Proposals::Proposal", association: :attachments
  end

  if Bullet.enable?
    config.before(:each) do
      Bullet.start_request
    end

    config.after(:each) do
      Bullet.perform_out_of_channel_notifications if Bullet.notification?
      Bullet.end_request
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
decidim-dev-0.29.1 lib/decidim/dev/test/rspec_support/bullet.rb
decidim-dev-0.29.0 lib/decidim/dev/test/rspec_support/bullet.rb
decidim-dev-0.29.0.rc4 lib/decidim/dev/test/rspec_support/bullet.rb
decidim-dev-0.29.0.rc3 lib/decidim/dev/test/rspec_support/bullet.rb
decidim-dev-0.29.0.rc2 lib/decidim/dev/test/rspec_support/bullet.rb
decidim-dev-0.29.0.rc1 lib/decidim/dev/test/rspec_support/bullet.rb