Created
August 20, 2013 02:06
-
-
Save arthurnn/6276351 to your computer and use it in GitHub Desktop.
trying to simulate https://github.com/mongoid/mongoid/issues/2985#issuecomment-22911190
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# encoding: utf-8 | |
require "spec_helper" | |
class Person | |
include Mongoid::Document | |
has_many :pets | |
field :name | |
end | |
class Pet | |
include Mongoid::Document | |
belongs_to :person | |
field :species | |
end | |
describe "ThreadSpec" do | |
context 'with two collections and many threads' do | |
let(:pet) { Pet.new } | |
let(:person) { Person.new } | |
before do | |
threads = (0...50).map do | |
Thread.new do | |
Pet.store_in collection: 'bands' | |
Person.store_in collection: 'artists' | |
end | |
end | |
threads.map(&:join) | |
end | |
after do | |
Pet.storage_options = nil | |
Person.storage_options = nil | |
end | |
it 'sets the right collection for Band' do | |
expect(Pet.collection.name).to eq('bands') | |
end | |
it 'sets the right collection for Artist' do | |
expect(Person.collection.name).to eq('artists') | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
running on:
gems