Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Resolved an issue with the Mongoid adapter + Mongoid 2.0 RC #15

Closed
wants to merge 4 commits into from

3 participants

@matt-royal

I ran into a problem with Pickle when using Mongoid 2.0.0.rc.8 . Mongoid::Document::PickleAdapter.model_classes assumes that all descendants of Mongoid::Document will be a model, but Mongoid 2.0 creates an empty nameless class that includes Mongoid::Document inside Mongoid::Config#destructive_fields. This nameless instance causes a NilClass exception inside model_classes.

I didn't see any tests for Mongoid in your suite (please let me know if I missed them), so I did not include a new test for this situation. The change is small and innocuous, though, so a test may not be necessary.

Thanks for all of your great work on Pickle,
-Matt Royal

Matt Royal and others added some commits
Matt Royal The Mongoid adapter ignores classes instances without a name
An anonymous class that includes Mongoid::Document is created in
Mongoid::Config#destructive_fields, which previously caused the Mongoid
adapter in Pickle to raise an exception in some cases
f91c6a2
Matt Royal Factory => FactoryGirl to avoid deprication warnings b9a7343
@pivotalpodbay pivotalpodbay Edited pickle.gemspec via GitHub 09b7dcb
@pivotalpodbay pivotalpodbay Specify version of rake so you don't get 0.9.0 by mistake. 37467e7
@chewi
Collaborator

Not sure if this is still necessary but seems harmless enough. Merged the first commit with a small adjustment.

@chewi chewi closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 23, 2011
  1. The Mongoid adapter ignores classes instances without a name

    Matt Royal authored
    An anonymous class that includes Mongoid::Document is created in
    Mongoid::Config#destructive_fields, which previously caused the Mongoid
    adapter in Pickle to raise an exception in some cases
Commits on Apr 28, 2011
  1. Factory => FactoryGirl to avoid deprication warnings

    Matt Royal authored
Commits on May 25, 2011
  1. @pivotalpodbay
  2. @pivotalpodbay
This page is out of date. Refresh to see the latest.
View
2  lib/pickle/adapter.rb
@@ -106,7 +106,7 @@ def create(attrs = {})
# factory-girl adapter
class FactoryGirl < Adapter
def self.factories
- (::Factory.factories.values rescue []).map {|factory| new(factory)}
+ (::FactoryGirl.factories.values rescue []).map {|factory| new(factory)}
end
def initialize(factory)
View
4 lib/pickle/adapters/mongoid.rb
@@ -12,7 +12,9 @@ def self.except_classes
# Gets a list of the available models for this adapter
def self.model_classes
- ObjectSpace.each_object(Class).to_a.select {|klass| klass.ancestors.include? Mongoid::Document}
+ ObjectSpace.each_object(Class).to_a.
+ select {|klass| klass.ancestors.include? Mongoid::Document}.
+ reject {|klass| klass.name.nil? }
end
# get a list of column names for a given class
View
2  pickle.gemspec
@@ -19,7 +19,7 @@ Gem::Specification.new do |s|
s.require_paths = ["lib"]
s.add_dependency "cucumber", ">=0.8"
- s.add_dependency "rake"
+ s.add_dependency "rake", ">=0.8.7"
s.add_development_dependency "rack", "~>1.2.1"
s.add_development_dependency "bundler"
Something went wrong with that request. Please try again.