Skip to content
Browse files

Fixed issues arising against Mongoid master:

- Updated dependencies to point to Mongoid master and Rspec 2.4
- :belongs_to_related is no longer the macro name, was changed to
  :referenced_in. Change fixes the failing spec.
  • Loading branch information...
1 parent f2620b5 commit 7ca59dbf86bd18b602009cd2138818b980f05a98 @durran durran committed with Jan 9, 2011
Showing with 75 additions and 11 deletions.
  1. +3 −3 Gemfile
  2. +64 −0 Gemfile.lock
  3. +8 −8 lib/machinist/mongoid.rb
View
6 Gemfile
@@ -1,10 +1,10 @@
# A sample Gemfile
source :gemcutter
-gem 'mongo', '1.0.1'
+gem 'mongo', '~> 1.1'
gem 'mongo_mapper', :git => 'git://github.com/jnunemaker/mongomapper.git'
-gem 'mongoid', "2.0.0.beta6"
+gem 'mongoid', :git => 'git://github.com/mongoid/mongoid.git'
gem 'machinist'
-gem 'rspec', ">= 2.0.0.beta.8"
+gem 'rspec', "2.4"
gem 'rake'
gem 'sham_rack'
View
64 Gemfile.lock
@@ -0,0 +1,64 @@
+GIT
+ remote: git://github.com/jnunemaker/mongomapper.git
+ revision: 985c9c67a642eeb8d00bce4108541a5406d1b2f2
+ specs:
+ mongo_mapper (0.8.6)
+ activesupport (>= 2.3.4)
+ jnunemaker-validatable (~> 1.8.4)
+ plucky (~> 0.3.6)
+
+GIT
+ remote: git://github.com/mongoid/mongoid.git
+ revision: c0cb411486454f0883d6f9477b0f3265f7340d98
+ specs:
+ mongoid (2.0.0.rc.1)
+ activemodel (~> 3.0)
+ mongo (~> 1.1.5)
+ tzinfo (~> 0.3.22)
+ will_paginate (~> 3.0.pre)
+
+GEM
+ remote: http://rubygems.org/
+ specs:
+ activemodel (3.0.3)
+ activesupport (= 3.0.3)
+ builder (~> 2.1.2)
+ i18n (~> 0.4)
+ activesupport (3.0.3)
+ bson (1.1.5)
+ builder (2.1.2)
+ diff-lcs (1.1.2)
+ i18n (0.5.0)
+ jnunemaker-validatable (1.8.4)
+ activesupport (>= 2.3.4)
+ machinist (1.0.6)
+ mongo (1.1.5)
+ bson (>= 1.1.5)
+ plucky (0.3.6)
+ mongo (~> 1.1)
+ rack (1.2.1)
+ rake (0.8.7)
+ rspec (2.4.0)
+ rspec-core (~> 2.4.0)
+ rspec-expectations (~> 2.4.0)
+ rspec-mocks (~> 2.4.0)
+ rspec-core (2.4.0)
+ rspec-expectations (2.4.0)
+ diff-lcs (~> 1.1.2)
+ rspec-mocks (2.4.0)
+ sham_rack (1.3.3)
+ rack
+ tzinfo (0.3.23)
+ will_paginate (3.0.pre2)
+
+PLATFORMS
+ ruby
+
+DEPENDENCIES
+ machinist
+ mongo (~> 1.1)
+ mongo_mapper!
+ mongoid!
+ rake
+ rspec (= 2.4)
+ sham_rack
View
16 lib/machinist/mongoid.rb
@@ -19,13 +19,13 @@ def assign_attribute(key, value)
end
end
end
-
+
class MongoidAdapter
class << self
def has_association?(object, attribute)
object.class.associations[attribute.to_s]
end
-
+
def class_for_association(object, attribute)
association = object.class.associations[attribute.to_s]
association && association.klass
@@ -35,17 +35,17 @@ def assigned_attributes_without_associations(lathe)
attributes = {}
lathe.assigned_attributes.each_pair do |attribute, value|
association = lathe.object.class.associations[attribute.to_s]
- if association && (association.macro == :belongs_to_related) && !value.nil?
+ if association && (association.macro == :referenced_in) && !value.nil?
attributes[association.foreign_key.to_sym] = value.id
else
attributes[attribute] = value
end
end
- attributes
- end
+ attributes
+ end
end
end
-
+
module MongoidExtensions
module Document
def make(*args, &block)
@@ -56,13 +56,13 @@ def make(*args, &block)
end
lathe.object(&block)
end
-
+
def make_unsaved(*args)
Machinist.with_save_nerfed { make(*args) }.tap do |object|
yield object if block_given?
end
end
-
+
def plan(*args)
lathe = Lathe.run(Machinist::MongoidAdapter, self.new, *args)
Machinist::MongoidAdapter.assigned_attributes_without_associations(lathe)

0 comments on commit 7ca59db

Please sign in to comment.
Something went wrong with that request. Please try again.