Uploaded image for project: 'Ruby Driver'
  1. Ruby Driver
  2. RUBY-1286

Mongoid.purge! fails after upgrading to mongo 2.5.0

    • Type: Icon: Bug Bug
    • Resolution: Done
    • Priority: Icon: Blocker - P1 Blocker - P1
    • 2.5.1
    • Affects Version/s: 2.5.0
    • Component/s: None
    • Labels:
      None
    • Environment:

      After update my Ruby on Rails Project, testing fail because the database cannot be cleaned after testing. Rspec fails with the following error:

        1) Survey::ChildrenSessionRatingScale should have "presence" validator on "relationship"
           Failure/Error: Mongoid.purge!
           
           Mongo::Error::NoServerAvailable:
             No server is available matching preference: #<Mongo::ServerSelector::Primary:0x70264958470380 tag_sets=[] max_staleness=nil> using server_selection_timeout=30 and local_threshold=0.015
           # ./spec/spec_helper.rb:21:in `block (2 levels) in <top (required)>'
      

      I rolled back all update and just updated mongoid. It does not update mongoid itself but the ruby driver mongo from 2.4.1 to 2.5. There must be some code changes that defunct Mongoid.purge! for some reasons.

      ENV['RAILS_ENV'] ||= 'test'
      require File.expand_path('../../config/environment', __FILE__)
      
      require 'rspec/rails'
      require 'rails/mongoid'
      require 'mongoid-rspec'
      # ...
      
      # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
      RSpec.configure do |config|
        config.include Mongoid::Matchers, type: :model
      
        config.before(:suite) do
          FactoryBot.reload
        end
      
        config.after(:each) do
          Mongoid.purge!
        end
        # ...
      end
      

      I was not able to investigate this in depth right now but I hope someone sees the problem and can help me with a quick fix.

      Greetings Markus

            Assignee:
            emily.stolfo Emily Stolfo
            Reporter:
            gurix Markus Graf
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: