Skip to content

Commit

Permalink
Update for MM 0.9.0
Browse files Browse the repository at this point in the history
  • Loading branch information
bkeepers committed Mar 8, 2011
1 parent 60f729b commit cbfe32e
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 26 deletions.
9 changes: 5 additions & 4 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
source "http://rubygems.org"
source :rubygems
source Source::Git.new("uri" => "git://github.com/jnunemaker/mongomapper.git")

gem 'i18n', '0.4.2'
gem 'bson_ext', '~> 1.1', :require => false
gemspec
gem 'i18n', '0.4.2'
gem 'bson_ext', '~> 1.2.4', :require => false
gemspec
40 changes: 24 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,31 +1,39 @@
GIT
remote: git://github.com/jnunemaker/mongomapper.git
revision: ae943070db905856f1844dd19b292c1a0eb2f580
specs:
mongo_mapper (0.9.0)
activemodel (~> 3.0.0)
activesupport (~> 3.0.0)
plucky (~> 0.3.6)

PATH
remote: .
specs:
joint (0.5.2)
joint (0.6.0)
mime-types
mongo_mapper (~> 0.8.6)
mongo_mapper (~> 0.9.0)
wand (~> 0.4)

GEM
remote: http://rubygems.org/
specs:
activesupport (3.0.3)
bson (1.1.5)
bson_ext (1.1.5)
activemodel (3.0.5)
activesupport (= 3.0.5)
builder (~> 2.1.2)
i18n (~> 0.4)
activesupport (3.0.5)
bson (1.2.4)
bson_ext (1.2.4)
builder (2.1.2)
i18n (0.4.2)
jnunemaker-matchy (0.4.0)
jnunemaker-validatable (1.8.4)
activesupport (>= 2.3.4)
mime-types (1.16)
mocha (0.9.10)
rake
mongo (1.1.5)
bson (>= 1.1.5)
mongo_mapper (0.8.6)
activesupport (>= 2.3.4)
jnunemaker-validatable (~> 1.8.4)
plucky (~> 0.3.6)
plucky (0.3.6)
mongo (1.2.4)
bson (>= 1.2.4)
plucky (0.3.7)
mongo (~> 1.1)
rake (0.8.7)
safe_shell (1.0.0)
Expand All @@ -38,12 +46,12 @@ PLATFORMS
ruby

DEPENDENCIES
bson_ext (~> 1.1)
bson_ext (~> 1.2.4)
i18n (= 0.4.2)
jnunemaker-matchy
joint!
mime-types
mocha
mongo_mapper (~> 0.8.6)
mongo_mapper (~> 0.9.0)
shoulda
wand (~> 0.4)
2 changes: 1 addition & 1 deletion joint.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |s|

s.add_dependency 'wand', '~> 0.4'
s.add_dependency 'mime-types'
s.add_dependency 'mongo_mapper', '~> 0.8.6'
s.add_dependency 'mongo_mapper', '~> 0.9.0'

s.add_development_dependency 'shoulda'
s.add_development_dependency 'mocha'
Expand Down
10 changes: 6 additions & 4 deletions lib/joint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
require 'wand'

module Joint
def self.configure(model)
model.class_inheritable_accessor :attachment_names
model.attachment_names = Set.new
model.send(:include, model.attachment_accessor_module)
extend ActiveSupport::Concern

included do
class_inheritable_accessor :attachment_names
self.attachment_names = Set.new
include attachment_accessor_module
end

def self.name(file)
Expand Down
1 change: 1 addition & 0 deletions lib/joint/attachment_proxy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ def type
def nil?
!@instance.send("#{@name}?")
end
alias_method :blank?, :nil?

def grid_io
@grid_io ||= @instance.grid.get(id)
Expand Down
2 changes: 1 addition & 1 deletion lib/joint/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module Joint
Version = '0.5.5'
Version = '0.6.0'
end
12 changes: 12 additions & 0 deletions test/test_joint.rb
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,11 @@ def @image.size
subject.file.nil?.should be(false)
end

should "respond with false when asked if the attachment is blank?" do
subject.image.blank?.should be(false)
subject.file.blank?.should be(false)
end

should "clear assigned attachments so they don't get uploaded twice" do
Mongo::Grid.any_instance.expects(:put).never
subject.save
Expand Down Expand Up @@ -247,6 +252,11 @@ def @image.size
subject.image.nil?.should be(true)
end

should "respond with true when asked if the attachment is blank?" do
subject.image = nil
subject.image.blank?.should be(true)
end

should "clear nil attachments after save and not attempt to delete again" do
Mongo::Grid.any_instance.expects(:delete).once
subject.image = nil
Expand Down Expand Up @@ -323,6 +333,8 @@ def @image.original_filename
include MongoMapper::Document
plugin Joint
attachment :file, :required => true

def self.name; "Foo"; end
end
end

Expand Down

0 comments on commit cbfe32e

Please sign in to comment.