Sha256: cd56c0b34ead7704572cd93dc942b59291bb9e0f37a489a25a849bdbca171188

Contents?: true

Size: 954 Bytes

Versions: 3

Compression:

Stored size: 954 Bytes

Contents

require 'bundler'
Bundler.require
require 'rspec'
require 'rspec/retry'

Mongoid.configure do |config|
  config.connect_to 'mongoid_orderable_test'
end

Mongoid.logger.level = Logger::INFO
Mongo::Logger.logger.level = Logger::INFO
Mongoid::Config.belongs_to_required_by_default = false

RSpec.configure do |config|
  config.order = 'random'

  config.before(:each) do
    Mongoid.purge!
    Mongoid.models.each do |model|
      model.create_indexes if model.name =~ /Mongoid::Orderable::Models/
    end
  end
end

require_relative 'support/models'

def set_transactions(enabled)
  Mongoid.models.each do |model|
    next unless model.respond_to?(:orderable_configs)
    model.orderable_configs.values.each do |config|
      config[:use_transactions] = enabled
    end
  end
end

def enable_transactions!
  before { set_transactions(true) }
end

def disable_transactions!
  before { set_transactions(false) }
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
mongoid_orderable-6.0.4 spec/spec_helper.rb
mongoid_orderable-6.0.3 spec/spec_helper.rb
mongoid_orderable-6.0.2 spec/spec_helper.rb