loose_change 0.3.4 → 0.3.5

Sign up to get free protection for your applications and to get access to all the features.
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.3.4
1
+ 0.3.5
@@ -26,6 +26,7 @@ module LooseChange
26
26
  # instance, whether or not that file has been saved back to
27
27
  # CouchDB. Will return nil if no attachment by that name exists.
28
28
  def attachment(name)
29
+ name = name.to_s
29
30
  return attachments[name][:file] if @attachments.try(:[], :name).try(:[], :file)
30
31
  begin
31
32
  result = retrieve_attachment(name)
@@ -47,7 +47,7 @@ module LooseChange
47
47
  model.new_record = false
48
48
  if hash['_attachments']
49
49
  attachment_names = hash['_attachments'].map {|name, _| name}
50
- model.attachments = attachment_names.inject({}) {|acc, name| acc[name.to_sym] = {:content_type => hash['_attachments'][name]['content_type']}; acc}
50
+ model.attachments = attachment_names.inject({}) {|acc, name| acc[name] = {:content_type => hash['_attachments'][name]['content_type']}; acc}
51
51
  end
52
52
  model
53
53
  end
data/loose_change.gemspec CHANGED
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{loose_change}
8
- s.version = "0.3.4"
8
+ s.version = "0.3.5"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Joshua Miller"]
@@ -15,21 +15,22 @@ class AttachmentTest < ActiveSupport::TestCase
15
15
  @model.attach :photo, File.open(File.join(File.dirname(__FILE__), 'resources', 'couchdb.png')), :content_type => 'image/png'
16
16
  assert @model.save
17
17
  @retrieved = AttachmentModel.find(@model.id)
18
- assert_equal({:photo => {:content_type => 'image/png'}}, @retrieved.attachments)
19
- assert_not_nil @retrieved.attachment(:photo)
18
+ assert_equal({"photo" => {:content_type => 'image/png'}}, @retrieved.attachments)
19
+ assert_not_nil @retrieved.attachment("photo")
20
20
  assert_equal @retrieved.attachment(:photo).size, @model.attachment(:photo).size
21
21
  end
22
22
 
23
23
  should "persist attachment between saves" do
24
- @model.attach :photo, File.open(File.join(File.dirname(__FILE__), 'resources', 'couchdb.png')), :content_type => 'image/png'
24
+ @model.attach "Photo", File.open(File.join(File.dirname(__FILE__), 'resources', 'couchdb.png')), :content_type => 'image/png'
25
25
  assert @model.save
26
26
  @retrieved = AttachmentModel.find(@model.id)
27
+ assert_not_nil @retrieved.attachment "Photo"
27
28
  @retrieved.name = "Photo"
28
29
  @retrieved.save
29
30
  @retrieved = AttachmentModel.find(@model.id)
30
- assert_equal({:photo => {:content_type => 'image/png'}}, @retrieved.attachments)
31
- assert_not_nil @retrieved.attachment(:photo)
32
- assert_equal @retrieved.attachment(:photo).size, @model.attachment(:photo).size
31
+ assert_equal({"Photo" => {:content_type => 'image/png'}}, @retrieved.attachments)
32
+ assert_not_nil @retrieved.attachment("Photo")
33
+ assert_equal @retrieved.attachment("Photo").size, @model.attachment("Photo").size
33
34
  assert @retrieved.save
34
35
  end
35
36
 
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 0
7
7
  - 3
8
- - 4
9
- version: 0.3.4
8
+ - 5
9
+ version: 0.3.5
10
10
  platform: ruby
11
11
  authors:
12
12
  - Joshua Miller
@@ -131,7 +131,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
131
131
  requirements:
132
132
  - - ">="
133
133
  - !ruby/object:Gem::Version
134
- hash: 1769435733236060489
134
+ hash: -1881381695233606524
135
135
  segments:
136
136
  - 0
137
137
  version: "0"