paperclip 2.3.8 → 2.3.9

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of paperclip might be problematic. Click here for more details.

Files changed (59) hide show
  1. data/{README.rdoc → README.md} +104 -54
  2. data/lib/paperclip.rb +2 -0
  3. data/lib/paperclip/attachment.rb +67 -38
  4. data/lib/paperclip/command_line.rb +7 -1
  5. data/lib/paperclip/interpolations.rb +17 -1
  6. data/lib/paperclip/storage.rb +1 -0
  7. data/lib/paperclip/storage/fog.rb +98 -0
  8. data/lib/paperclip/storage/s3.rb +5 -5
  9. data/lib/paperclip/version.rb +1 -1
  10. data/test/attachment_test.rb +117 -0
  11. data/test/command_line_test.rb +5 -0
  12. data/test/fixtures/uppercase.PNG +0 -0
  13. data/test/fog_test.rb +107 -0
  14. data/test/helper.rb +1 -1
  15. data/test/integration_test.rb +88 -0
  16. data/test/interpolations_test.rb +17 -1
  17. data/test/paperclip_test.rb +30 -0
  18. data/test/storage_test.rb +23 -0
  19. metadata +47 -80
  20. data/lib/paperclip.rbc +0 -5202
  21. data/lib/paperclip/attachment.rbc +0 -6393
  22. data/lib/paperclip/callback_compatability.rbc +0 -1649
  23. data/lib/paperclip/command_line.rbc +0 -1952
  24. data/lib/paperclip/geometry.rbc +0 -2141
  25. data/lib/paperclip/glue.rbc +0 -685
  26. data/lib/paperclip/interpolations.rbc +0 -2205
  27. data/lib/paperclip/iostream.rbc +0 -905
  28. data/lib/paperclip/matchers.rbc +0 -267
  29. data/lib/paperclip/matchers/have_attached_file_matcher.rbc +0 -1258
  30. data/lib/paperclip/matchers/validate_attachment_content_type_matcher.rbc +0 -1660
  31. data/lib/paperclip/matchers/validate_attachment_presence_matcher.rbc +0 -1304
  32. data/lib/paperclip/matchers/validate_attachment_size_matcher.rbc +0 -2160
  33. data/lib/paperclip/processor.rbc +0 -911
  34. data/lib/paperclip/railtie.rbc +0 -680
  35. data/lib/paperclip/storage.rbc +0 -69
  36. data/lib/paperclip/storage/filesystem.rbc +0 -1402
  37. data/lib/paperclip/storage/s3.rbc +0 -3489
  38. data/lib/paperclip/style.rbc +0 -1571
  39. data/lib/paperclip/thumbnail.rbc +0 -1648
  40. data/lib/paperclip/upfile.rbc +0 -1619
  41. data/lib/paperclip/version.rbc +0 -176
  42. data/shoulda_macros/paperclip.rbc +0 -2415
  43. data/test/attachment_test.rbc +0 -22952
  44. data/test/command_line_test.rbc +0 -4307
  45. data/test/geometry_test.rbc +0 -5181
  46. data/test/helper.rbc +0 -3971
  47. data/test/integration_test.rbc +0 -13137
  48. data/test/interpolations_test.rbc +0 -3432
  49. data/test/iostream_test.rbc +0 -1889
  50. data/test/matchers/have_attached_file_matcher_test.rbc +0 -622
  51. data/test/matchers/validate_attachment_content_type_matcher_test.rbc +0 -1174
  52. data/test/matchers/validate_attachment_presence_matcher_test.rbc +0 -622
  53. data/test/matchers/validate_attachment_size_matcher_test.rbc +0 -1658
  54. data/test/paperclip_test.rbc +0 -7407
  55. data/test/processor_test.rbc +0 -314
  56. data/test/storage_test.rbc +0 -10294
  57. data/test/style_test.rbc +0 -3752
  58. data/test/thumbnail_test.rbc +0 -6803
  59. data/test/upfile_test.rbc +0 -1635
@@ -90,7 +90,7 @@ end
90
90
  class FakeModel
91
91
  attr_accessor :avatar_file_name,
92
92
  :avatar_file_size,
93
- :avatar_last_updated,
93
+ :avatar_updated_at,
94
94
  :avatar_content_type,
95
95
  :avatar_fingerprint,
96
96
  :id
@@ -34,6 +34,22 @@ class IntegrationTest < Test::Unit::TestCase
34
34
  should "create its thumbnails properly" do
35
35
  assert_match /\b50x50\b/, `identify "#{@dummy.avatar.path(:thumb)}"`
36
36
  end
37
+
38
+ context 'reprocessing with unreadable original' do
39
+ setup { File.chmod(0000, @dummy.avatar.path) }
40
+
41
+ should "not raise an error" do
42
+ assert_nothing_raised do
43
+ @dummy.avatar.reprocess!
44
+ end
45
+ end
46
+
47
+ should "return false" do
48
+ assert ! @dummy.avatar.reprocess!
49
+ end
50
+
51
+ teardown { File.chmod(0644, @dummy.avatar.path) }
52
+ end
37
53
 
38
54
  context "redefining its attachment styles" do
39
55
  setup do
@@ -53,6 +69,78 @@ class IntegrationTest < Test::Unit::TestCase
53
69
  end
54
70
  end
55
71
 
72
+ context "Attachment" do
73
+ setup do
74
+ @thumb_path = "./test/../public/system/avatars/1/thumb/5k.png"
75
+ File.delete(@thumb_path) if File.exists?(@thumb_path)
76
+ rebuild_model :styles => { :thumb => "50x50#" }
77
+ @dummy = Dummy.new
78
+ @file = File.new(File.join(File.dirname(__FILE__),
79
+ "fixtures",
80
+ "5k.png"), 'rb')
81
+
82
+ end
83
+
84
+ teardown { @file.close }
85
+
86
+ should "not create the thumbnails upon saving when post-processing is disabled" do
87
+ @dummy.avatar.post_processing = false
88
+ @dummy.avatar = @file
89
+ assert @dummy.save
90
+ assert !File.exists?(@thumb_path)
91
+ end
92
+
93
+ should "create the thumbnails upon saving when post_processing is enabled" do
94
+ @dummy.avatar.post_processing = true
95
+ @dummy.avatar = @file
96
+ assert @dummy.save
97
+ assert File.exists?(@thumb_path)
98
+ end
99
+ end
100
+
101
+ context "Attachment with no generated thumbnails" do
102
+ setup do
103
+ @thumb_small_path = "./test/../public/system/avatars/1/thumb_small/5k.png"
104
+ @thumb_large_path = "./test/../public/system/avatars/1/thumb_large/5k.png"
105
+ File.delete(@thumb_small_path) if File.exists?(@thumb_small_path)
106
+ File.delete(@thumb_large_path) if File.exists?(@thumb_large_path)
107
+ rebuild_model :styles => { :thumb_small => "50x50#", :thumb_large => "60x60#" }
108
+ @dummy = Dummy.new
109
+ @file = File.new(File.join(File.dirname(__FILE__),
110
+ "fixtures",
111
+ "5k.png"), 'rb')
112
+
113
+ @dummy.avatar.post_processing = false
114
+ @dummy.avatar = @file
115
+ assert @dummy.save
116
+ @dummy.avatar.post_processing = true
117
+ end
118
+
119
+ teardown { @file.close }
120
+
121
+ should "allow us to create all thumbnails in one go" do
122
+ assert !File.exists?(@thumb_small_path)
123
+ assert !File.exists?(@thumb_large_path)
124
+
125
+ @dummy.avatar.reprocess!
126
+
127
+ assert File.exists?(@thumb_small_path)
128
+ assert File.exists?(@thumb_large_path)
129
+ end
130
+
131
+ should "allow us to selectively create each thumbnail" do
132
+ assert !File.exists?(@thumb_small_path)
133
+ assert !File.exists?(@thumb_large_path)
134
+
135
+ @dummy.avatar.reprocess! :thumb_small
136
+ assert File.exists?(@thumb_small_path)
137
+ assert !File.exists?(@thumb_large_path)
138
+
139
+ @dummy.avatar.reprocess! :thumb_large
140
+ assert File.exists?(@thumb_large_path)
141
+ end
142
+ end
143
+
56
144
  context "A model that modifies its original" do
57
145
  setup do
58
146
  rebuild_model :styles => { :original => "2x2#" }
@@ -112,9 +112,25 @@ class InterpolationsTest < Test::Unit::TestCase
112
112
 
113
113
  should "return the timestamp" do
114
114
  now = Time.now
115
+ zone = 'UTC'
115
116
  attachment = mock
116
117
  attachment.expects(:instance_read).with(:updated_at).returns(now)
117
- assert_equal now.to_s, Paperclip::Interpolations.timestamp(attachment, :style)
118
+ attachment.expects(:time_zone).returns(zone)
119
+ assert_equal now.in_time_zone(zone).to_s, Paperclip::Interpolations.timestamp(attachment, :style)
120
+ end
121
+
122
+ should "return updated_at" do
123
+ attachment = mock
124
+ seconds_since_epoch = 1234567890
125
+ attachment.expects(:updated_at).returns(seconds_since_epoch)
126
+ assert_equal seconds_since_epoch, Paperclip::Interpolations.updated_at(attachment, :style)
127
+ end
128
+
129
+ should "return hash" do
130
+ attachment = mock
131
+ fake_hash = "a_wicked_secure_hash"
132
+ attachment.expects(:hash).returns(fake_hash)
133
+ assert_equal fake_hash, Paperclip::Interpolations.hash(attachment, :style)
118
134
  end
119
135
 
120
136
  should "call all expected interpolations with the given arguments" do
@@ -252,6 +252,21 @@ class PaperclipTest < Test::Unit::TestCase
252
252
  should_validate validation, options, valid_file, invalid_file
253
253
  end
254
254
 
255
+ context "with content_type validation and lambda message" do
256
+ context "and assigned an invalid file" do
257
+ setup do
258
+ Dummy.send(:"validates_attachment_content_type", :avatar, :content_type => %r{image/.*}, :message => lambda {'lambda content type message'})
259
+ @dummy = Dummy.new
260
+ @dummy.avatar &&= File.open(File.join(FIXTURES_DIR, "text.txt"), "rb")
261
+ @dummy.valid?
262
+ end
263
+
264
+ should "have a content type error message" do
265
+ assert [@dummy.errors[:avatar_content_type]].flatten.any?{|error| error =~ %r/lambda content type message/ }
266
+ end
267
+ end
268
+ end
269
+
255
270
  context "with size validation and less_than 10240 option" do
256
271
  context "and assigned an invalid file" do
257
272
  setup do
@@ -267,5 +282,20 @@ class PaperclipTest < Test::Unit::TestCase
267
282
  end
268
283
  end
269
284
 
285
+ context "with size validation and less_than 10240 option with lambda message" do
286
+ context "and assigned an invalid file" do
287
+ setup do
288
+ Dummy.send(:"validates_attachment_size", :avatar, :less_than => 10240, :message => lambda {'lambda between 0 and 10240 bytes'})
289
+ @dummy = Dummy.new
290
+ @dummy.avatar &&= File.open(File.join(FIXTURES_DIR, "12k.png"), "rb")
291
+ @dummy.valid?
292
+ end
293
+
294
+ should "have a file size min/max error message" do
295
+ assert [@dummy.errors[:avatar_file_size]].flatten.any?{|error| error =~ %r/lambda between 0 and 10240 bytes/ }
296
+ end
297
+ end
298
+ end
299
+
270
300
  end
271
301
  end
@@ -7,6 +7,29 @@ class StorageTest < Test::Unit::TestCase
7
7
  Object.const_set(:Rails, stub('Rails', :env => env))
8
8
  end
9
9
  end
10
+
11
+ context "filesystem" do
12
+ setup do
13
+ rebuild_model :styles => { :thumbnail => "25x25#" }
14
+ @dummy = Dummy.create!
15
+
16
+ @dummy.avatar = File.open(File.join(File.dirname(__FILE__), "fixtures", "5k.png"))
17
+ end
18
+
19
+ should "allow file assignment" do
20
+ assert @dummy.save
21
+ end
22
+
23
+ should "store the original" do
24
+ @dummy.save
25
+ assert File.exists?(@dummy.avatar.path)
26
+ end
27
+
28
+ should "store the thumbnail" do
29
+ @dummy.save
30
+ assert File.exists?(@dummy.avatar.path(:thumbnail))
31
+ end
32
+ end
10
33
 
11
34
  context "Parsing S3 credentials" do
12
35
  setup do
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: paperclip
3
3
  version: !ruby/object:Gem::Version
4
- hash: 19
4
+ hash: 17
5
5
  prerelease: false
6
6
  segments:
7
7
  - 2
8
8
  - 3
9
- - 8
10
- version: 2.3.8
9
+ - 9
10
+ version: 2.3.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - Jon Yurek
@@ -15,39 +15,45 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2010-12-15 00:00:00 -05:00
18
+ date: 2011-04-06 00:00:00 -04:00
19
19
  default_executable:
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- version_requirements: &id001 !ruby/object:Gem::Requirement
22
+ name: activerecord
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
23
25
  none: false
24
26
  requirements:
25
- - - ">="
27
+ - - ~>
26
28
  - !ruby/object:Gem::Version
27
29
  hash: 3
28
30
  segments:
31
+ - 2
32
+ - 3
29
33
  - 0
30
- version: "0"
31
- requirement: *id001
34
+ version: 2.3.0
32
35
  type: :runtime
33
- name: activerecord
34
- prerelease: false
36
+ version_requirements: *id001
35
37
  - !ruby/object:Gem::Dependency
36
- version_requirements: &id002 !ruby/object:Gem::Requirement
38
+ name: activesupport
39
+ prerelease: false
40
+ requirement: &id002 !ruby/object:Gem::Requirement
37
41
  none: false
38
42
  requirements:
39
- - - ">="
43
+ - - ~>
40
44
  - !ruby/object:Gem::Version
41
- hash: 3
45
+ hash: 7
42
46
  segments:
43
- - 0
44
- version: "0"
45
- requirement: *id002
47
+ - 2
48
+ - 3
49
+ - 2
50
+ version: 2.3.2
46
51
  type: :runtime
47
- name: activesupport
48
- prerelease: false
52
+ version_requirements: *id002
49
53
  - !ruby/object:Gem::Dependency
50
- version_requirements: &id003 !ruby/object:Gem::Requirement
54
+ name: shoulda
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
51
57
  none: false
52
58
  requirements:
53
59
  - - ">="
@@ -56,12 +62,12 @@ dependencies:
56
62
  segments:
57
63
  - 0
58
64
  version: "0"
59
- requirement: *id003
60
65
  type: :development
61
- name: shoulda
62
- prerelease: false
66
+ version_requirements: *id003
63
67
  - !ruby/object:Gem::Dependency
64
- version_requirements: &id004 !ruby/object:Gem::Requirement
68
+ name: appraisal
69
+ prerelease: false
70
+ requirement: &id004 !ruby/object:Gem::Requirement
65
71
  none: false
66
72
  requirements:
67
73
  - - ">="
@@ -70,12 +76,12 @@ dependencies:
70
76
  segments:
71
77
  - 0
72
78
  version: "0"
73
- requirement: *id004
74
79
  type: :development
75
- name: appraisal
76
- prerelease: false
80
+ version_requirements: *id004
77
81
  - !ruby/object:Gem::Dependency
78
- version_requirements: &id005 !ruby/object:Gem::Requirement
82
+ name: mocha
83
+ prerelease: false
84
+ requirement: &id005 !ruby/object:Gem::Requirement
79
85
  none: false
80
86
  requirements:
81
87
  - - ">="
@@ -84,12 +90,12 @@ dependencies:
84
90
  segments:
85
91
  - 0
86
92
  version: "0"
87
- requirement: *id005
88
93
  type: :development
89
- name: mocha
90
- prerelease: false
94
+ version_requirements: *id005
91
95
  - !ruby/object:Gem::Dependency
92
- version_requirements: &id006 !ruby/object:Gem::Requirement
96
+ name: aws-s3
97
+ prerelease: false
98
+ requirement: &id006 !ruby/object:Gem::Requirement
93
99
  none: false
94
100
  requirements:
95
101
  - - ">="
@@ -98,12 +104,12 @@ dependencies:
98
104
  segments:
99
105
  - 0
100
106
  version: "0"
101
- requirement: *id006
102
107
  type: :development
103
- name: aws-s3
104
- prerelease: false
108
+ version_requirements: *id006
105
109
  - !ruby/object:Gem::Dependency
106
- version_requirements: &id007 !ruby/object:Gem::Requirement
110
+ name: sqlite3-ruby
111
+ prerelease: false
112
+ requirement: &id007 !ruby/object:Gem::Requirement
107
113
  none: false
108
114
  requirements:
109
115
  - - ">="
@@ -112,10 +118,8 @@ dependencies:
112
118
  segments:
113
119
  - 0
114
120
  version: "0"
115
- requirement: *id007
116
121
  type: :development
117
- name: sqlite3-ruby
118
- prerelease: false
122
+ version_requirements: *id007
119
123
  description: Easy upload management for ActiveRecord
120
124
  email: jyurek@thoughtbot.com
121
125
  executables: []
@@ -123,9 +127,9 @@ executables: []
123
127
  extensions: []
124
128
 
125
129
  extra_rdoc_files:
126
- - README.rdoc
130
+ - README.md
127
131
  files:
128
- - README.rdoc
132
+ - README.md
129
133
  - LICENSE
130
134
  - Rakefile
131
135
  - init.rb
@@ -133,53 +137,30 @@ files:
133
137
  - lib/generators/paperclip/templates/paperclip_migration.rb.erb
134
138
  - lib/generators/paperclip/USAGE
135
139
  - lib/paperclip/attachment.rb
136
- - lib/paperclip/attachment.rbc
137
140
  - lib/paperclip/callback_compatability.rb
138
- - lib/paperclip/callback_compatability.rbc
139
141
  - lib/paperclip/command_line.rb
140
- - lib/paperclip/command_line.rbc
141
142
  - lib/paperclip/geometry.rb
142
- - lib/paperclip/geometry.rbc
143
- - lib/paperclip/glue.rbc
144
143
  - lib/paperclip/interpolations.rb
145
- - lib/paperclip/interpolations.rbc
146
144
  - lib/paperclip/iostream.rb
147
- - lib/paperclip/iostream.rbc
148
145
  - lib/paperclip/matchers/have_attached_file_matcher.rb
149
- - lib/paperclip/matchers/have_attached_file_matcher.rbc
150
146
  - lib/paperclip/matchers/validate_attachment_content_type_matcher.rb
151
- - lib/paperclip/matchers/validate_attachment_content_type_matcher.rbc
152
147
  - lib/paperclip/matchers/validate_attachment_presence_matcher.rb
153
- - lib/paperclip/matchers/validate_attachment_presence_matcher.rbc
154
148
  - lib/paperclip/matchers/validate_attachment_size_matcher.rb
155
- - lib/paperclip/matchers/validate_attachment_size_matcher.rbc
156
149
  - lib/paperclip/matchers.rb
157
- - lib/paperclip/matchers.rbc
158
150
  - lib/paperclip/processor.rb
159
- - lib/paperclip/processor.rbc
160
151
  - lib/paperclip/railtie.rb
161
- - lib/paperclip/railtie.rbc
162
152
  - lib/paperclip/storage/filesystem.rb
163
- - lib/paperclip/storage/filesystem.rbc
153
+ - lib/paperclip/storage/fog.rb
164
154
  - lib/paperclip/storage/s3.rb
165
- - lib/paperclip/storage/s3.rbc
166
155
  - lib/paperclip/storage.rb
167
- - lib/paperclip/storage.rbc
168
156
  - lib/paperclip/style.rb
169
- - lib/paperclip/style.rbc
170
157
  - lib/paperclip/thumbnail.rb
171
- - lib/paperclip/thumbnail.rbc
172
158
  - lib/paperclip/upfile.rb
173
- - lib/paperclip/upfile.rbc
174
159
  - lib/paperclip/version.rb
175
- - lib/paperclip/version.rbc
176
160
  - lib/paperclip.rb
177
- - lib/paperclip.rbc
178
161
  - lib/tasks/paperclip.rake
179
162
  - test/attachment_test.rb
180
- - test/attachment_test.rbc
181
163
  - test/command_line_test.rb
182
- - test/command_line_test.rbc
183
164
  - test/database.yml
184
165
  - test/fixtures/12k.png
185
166
  - test/fixtures/50x50.png
@@ -188,42 +169,28 @@ files:
188
169
  - test/fixtures/s3.yml
189
170
  - test/fixtures/text.txt
190
171
  - test/fixtures/twopage.pdf
172
+ - test/fixtures/uppercase.PNG
173
+ - test/fog_test.rb
191
174
  - test/geometry_test.rb
192
- - test/geometry_test.rbc
193
175
  - test/helper.rb
194
- - test/helper.rbc
195
176
  - test/integration_test.rb
196
- - test/integration_test.rbc
197
177
  - test/interpolations_test.rb
198
- - test/interpolations_test.rbc
199
178
  - test/iostream_test.rb
200
- - test/iostream_test.rbc
201
179
  - test/matchers/have_attached_file_matcher_test.rb
202
- - test/matchers/have_attached_file_matcher_test.rbc
203
180
  - test/matchers/validate_attachment_content_type_matcher_test.rb
204
- - test/matchers/validate_attachment_content_type_matcher_test.rbc
205
181
  - test/matchers/validate_attachment_presence_matcher_test.rb
206
- - test/matchers/validate_attachment_presence_matcher_test.rbc
207
182
  - test/matchers/validate_attachment_size_matcher_test.rb
208
- - test/matchers/validate_attachment_size_matcher_test.rbc
209
183
  - test/paperclip_test.rb
210
- - test/paperclip_test.rbc
211
184
  - test/processor_test.rb
212
- - test/processor_test.rbc
213
185
  - test/storage_test.rb
214
- - test/storage_test.rbc
215
186
  - test/style_test.rb
216
- - test/style_test.rbc
217
187
  - test/thumbnail_test.rb
218
- - test/thumbnail_test.rbc
219
188
  - test/upfile_test.rb
220
- - test/upfile_test.rbc
221
189
  - rails/init.rb
222
190
  - generators/paperclip/paperclip_generator.rb
223
191
  - generators/paperclip/templates/paperclip_migration.rb.erb
224
192
  - generators/paperclip/USAGE
225
193
  - shoulda_macros/paperclip.rb
226
- - shoulda_macros/paperclip.rbc
227
194
  has_rdoc: true
228
195
  homepage: http://www.thoughtbot.com/projects/paperclip
229
196
  licenses: []