Permalink
Browse files

Updated to work with latest MM and Ruby Driver.

  • Loading branch information...
1 parent b5c1741 commit d2d89e1b810824a559cb14388ea0951fdafa7312 @jnunemaker jnunemaker committed Apr 19, 2010
Showing with 10 additions and 9 deletions.
  1. +1 −1 Rakefile
  2. +3 −2 lib/joint.rb
  3. +6 −6 test/test_joint.rb
View
2 Rakefile
@@ -18,12 +18,12 @@ Jeweler::Tasks.new do |gem|
gem.add_dependency 'wand', '>= 0.2.1'
gem.add_dependency 'mime-types'
+ gem.add_dependency 'mongo_mapper', '>= 0.7.4'
gem.add_development_dependency 'jeweler'
gem.add_development_dependency 'shoulda'
gem.add_development_dependency 'mocha'
gem.add_development_dependency 'jnunemaker-matchy'
- gem.add_development_dependency 'mongo_mapper', '>= 0.7.2'
end
Jeweler::GemcutterTasks.new
View
5 lib/joint.rb
@@ -36,7 +36,7 @@ def #{name}=(file)
if file.nil?
nil_attachments << :#{name}
else
- self["#{name}_id"] = Mongo::ObjectID.new if self["#{name}_id"].nil?
+ self["#{name}_id"] = BSON::ObjectID.new if self["#{name}_id"].nil?
self["#{name}_size"] = File.size(file)
self["#{name}_type"] = Wand.wave(file.path)
self["#{name}_name"] = Joint.file_name(file)
@@ -67,8 +67,9 @@ def save_attachments
next unless io.respond_to?(:read)
io.rewind if io.respond_to?(:rewind)
grid.delete(send(name).id)
- grid.put(io.read, send(name).name, {
+ grid.put(io.read, {
:_id => send(name).id,
+ :filename => send(name).name,
:content_type => send(name).type,
})
end
View
12 test/test_joint.rb
@@ -112,8 +112,8 @@ def teardown
subject.image_id.should_not be_nil
subject.file_id.should_not be_nil
- subject.image_id.should be_instance_of(Mongo::ObjectID)
- subject.file_id.should be_instance_of(Mongo::ObjectID)
+ subject.image_id.should be_instance_of(BSON::ObjectID)
+ subject.file_id.should be_instance_of(BSON::ObjectID)
end
should "allow accessing keys through attachment proxy" do
@@ -126,8 +126,8 @@ def teardown
subject.image.id.should_not be_nil
subject.file.id.should_not be_nil
- subject.image.id.should be_instance_of(Mongo::ObjectID)
- subject.file.id.should be_instance_of(Mongo::ObjectID)
+ subject.image.id.should be_instance_of(BSON::ObjectID)
+ subject.file.id.should be_instance_of(BSON::ObjectID)
end
should "proxy unknown methods to GridIO object" do
@@ -251,8 +251,8 @@ def teardown
subject.image?.should be(false)
end
- should "raise Mongo::GridError" do
- assert_raises(Mongo::GridError) { subject.image.read }
+ should "raise Mongo::GridFileNotFound" do
+ assert_raises(Mongo::GridFileNotFound) { subject.image.read }
end
end

0 comments on commit d2d89e1

Please sign in to comment.