carrierwave-mongoid 0.1.5 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2008-2012 Jonas Nicklas
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -38,6 +38,16 @@ module CarrierWave
38
38
  super
39
39
  end
40
40
 
41
+ # Overrides Mongoid's default dirty behavior to instead work more like
42
+ # ActiveRecord's. Mongoid doesn't deem an attribute as changed unless
43
+ # the new value is different than the original. Given that CarrierWave
44
+ # caches files before save, it's necessary to know that there's a
45
+ # pending change even though the attribute value itself might not
46
+ # reflect that yet.
47
+ def #{column}_changed?
48
+ changed_attributes.has_key?("#{column}")
49
+ end
50
+
41
51
  def find_previous_model_for_#{column}
42
52
  if self.embedded?
43
53
  ancestors = [[ self.metadata.key, self._parent ]].tap { |x| x.unshift([ x.first.last.metadata.key, x.first.last._parent ]) while x.first.last.embedded? }
@@ -1,5 +1,5 @@
1
1
  module Carrierwave
2
2
  module Mongoid
3
- VERSION = "0.1.5"
3
+ VERSION = "0.1.6"
4
4
  end
5
5
  end
@@ -52,7 +52,7 @@ module CarrierWave
52
52
  unless @uploader.grid_fs_access_url
53
53
  nil
54
54
  else
55
- [@uploader.grid_fs_access_url, @path].join("/").squeeze("/")
55
+ [@uploader.grid_fs_access_url.chomp("/"), @path].join("/")
56
56
  end
57
57
  end
58
58
 
data/spec/mongoid_spec.rb CHANGED
@@ -256,7 +256,6 @@ describe CarrierWave::Mongoid do
256
256
  end
257
257
 
258
258
  it "should mark image as changed when saving a new image" do
259
- pending "This isn't working with Mongoid's current Dirty module. Mongoid's *_changed? methods don't behave the same as ActiveModel's *_changed? methods."
260
259
  @doc.image_changed?.should be_false
261
260
  @doc.image = stub_file("test.jpeg")
262
261
  @doc.image_changed?.should be_true
@@ -60,11 +60,16 @@ shared_examples_for "a GridFS connection" do
60
60
  @grid_fs_file.url.should be_nil
61
61
  end
62
62
 
63
- it "should return a URL if configured" do
63
+ it "should return a URL path if configured" do
64
64
  @uploader.stub!(:grid_fs_access_url).and_return("/image/show")
65
65
  @grid_fs_file.url.should == "/image/show/uploads/bar.txt"
66
66
  end
67
67
 
68
+ it "should return an absolute URL if configured" do
69
+ @uploader.stub!(:grid_fs_access_url).and_return("http://example.com/images/")
70
+ @grid_fs_file.url.should == "http://example.com/images/uploads/bar.txt"
71
+ end
72
+
68
73
  it "should be deletable" do
69
74
  @grid_fs_file.delete
70
75
  lambda {@grid.open('uploads/bar.txt', 'r')}.should raise_error(Mongo::GridFileNotFound)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: carrierwave-mongoid
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -10,11 +10,11 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2012-03-29 00:00:00.000000000 Z
13
+ date: 2012-03-31 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: carrierwave
17
- requirement: &70093414050040 !ruby/object:Gem::Requirement
17
+ requirement: &70244342360100 !ruby/object:Gem::Requirement
18
18
  none: false
19
19
  requirements:
20
20
  - - ~>
@@ -22,10 +22,10 @@ dependencies:
22
22
  version: 0.5.6
23
23
  type: :runtime
24
24
  prerelease: false
25
- version_requirements: *70093414050040
25
+ version_requirements: *70244342360100
26
26
  - !ruby/object:Gem::Dependency
27
27
  name: mongoid
28
- requirement: &70093414036060 !ruby/object:Gem::Requirement
28
+ requirement: &70244342346100 !ruby/object:Gem::Requirement
29
29
  none: false
30
30
  requirements:
31
31
  - - ~>
@@ -33,10 +33,10 @@ dependencies:
33
33
  version: '2.1'
34
34
  type: :runtime
35
35
  prerelease: false
36
- version_requirements: *70093414036060
36
+ version_requirements: *70244342346100
37
37
  - !ruby/object:Gem::Dependency
38
38
  name: rspec
39
- requirement: &70093414035240 !ruby/object:Gem::Requirement
39
+ requirement: &70244342345260 !ruby/object:Gem::Requirement
40
40
  none: false
41
41
  requirements:
42
42
  - - ~>
@@ -44,10 +44,10 @@ dependencies:
44
44
  version: '2.6'
45
45
  type: :development
46
46
  prerelease: false
47
- version_requirements: *70093414035240
47
+ version_requirements: *70244342345260
48
48
  - !ruby/object:Gem::Dependency
49
49
  name: bson_ext
50
- requirement: &70093414034580 !ruby/object:Gem::Requirement
50
+ requirement: &70244342344600 !ruby/object:Gem::Requirement
51
51
  none: false
52
52
  requirements:
53
53
  - - ~>
@@ -55,10 +55,10 @@ dependencies:
55
55
  version: '1.3'
56
56
  type: :development
57
57
  prerelease: false
58
- version_requirements: *70093414034580
58
+ version_requirements: *70244342344600
59
59
  - !ruby/object:Gem::Dependency
60
60
  name: rake
61
- requirement: &70093414034080 !ruby/object:Gem::Requirement
61
+ requirement: &70244342344100 !ruby/object:Gem::Requirement
62
62
  none: false
63
63
  requirements:
64
64
  - - ~>
@@ -66,10 +66,10 @@ dependencies:
66
66
  version: '0.9'
67
67
  type: :development
68
68
  prerelease: false
69
- version_requirements: *70093414034080
69
+ version_requirements: *70244342344100
70
70
  - !ruby/object:Gem::Dependency
71
71
  name: mini_magick
72
- requirement: &70093414033660 !ruby/object:Gem::Requirement
72
+ requirement: &70244342343680 !ruby/object:Gem::Requirement
73
73
  none: false
74
74
  requirements:
75
75
  - - ! '>='
@@ -77,7 +77,7 @@ dependencies:
77
77
  version: '0'
78
78
  type: :development
79
79
  prerelease: false
80
- version_requirements: *70093414033660
80
+ version_requirements: *70244342343680
81
81
  description: Mongoid support for CarrierWave
82
82
  email:
83
83
  - jonas.nicklas@gmail.com
@@ -87,6 +87,7 @@ extra_rdoc_files: []
87
87
  files:
88
88
  - .gitignore
89
89
  - Gemfile
90
+ - LICENSE
90
91
  - README.md
91
92
  - Rakefile
92
93
  - carrierwave-mongoid.gemspec
@@ -118,7 +119,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
118
119
  version: '0'
119
120
  segments:
120
121
  - 0
121
- hash: 887805465808785246
122
+ hash: -703899468836926150
122
123
  required_rubygems_version: !ruby/object:Gem::Requirement
123
124
  none: false
124
125
  requirements:
@@ -127,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
127
128
  version: '0'
128
129
  segments:
129
130
  - 0
130
- hash: 887805465808785246
131
+ hash: -703899468836926150
131
132
  requirements: []
132
133
  rubyforge_project: carrierwave-mongoid
133
134
  rubygems_version: 1.8.11