paperclip 3.0.2 → 3.0.3
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.
- data/CONTRIBUTING.md +34 -2
- data/NEWS +33 -1
- data/README.md +20 -6
- data/RUNNING_TESTS.md +4 -0
- data/features/basic_integration.feature +4 -2
- data/features/support/fakeweb.rb +7 -0
- data/lib/paperclip.rb +2 -1
- data/lib/paperclip/attachment.rb +28 -16
- data/lib/paperclip/glue.rb +8 -0
- data/lib/paperclip/helpers.rb +4 -16
- data/lib/paperclip/instance_methods.rb +1 -1
- data/lib/paperclip/io_adapters/attachment_adapter.rb +13 -4
- data/lib/paperclip/io_adapters/file_adapter.rb +5 -3
- data/lib/paperclip/io_adapters/stringio_adapter.rb +4 -2
- data/lib/paperclip/io_adapters/uploaded_file_adapter.rb +3 -1
- data/lib/paperclip/missing_attachment_styles.rb +5 -8
- data/lib/paperclip/railtie.rb +4 -7
- data/lib/paperclip/storage/fog.rb +11 -0
- data/lib/paperclip/storage/s3.rb +26 -0
- data/lib/paperclip/tempfile.rb +7 -5
- data/lib/paperclip/validators.rb +1 -0
- data/lib/paperclip/validators/attachment_content_type_validator.rb +8 -1
- data/lib/paperclip/version.rb +1 -1
- data/lib/tasks/paperclip.rake +1 -1
- data/paperclip.gemspec +3 -3
- data/test/attachment_test.rb +77 -23
- data/test/geometry_test.rb +3 -3
- data/test/helper.rb +10 -10
- data/test/integration_test.rb +103 -56
- data/test/{attachment_adapter_test.rb → io_adapters/attachment_adapter_test.rb} +4 -1
- data/test/io_adapters/file_adapter_test.rb +88 -0
- data/test/{identity_adapter_test.rb → io_adapters/identity_adapter_test.rb} +0 -0
- data/test/{nil_adapter_test.rb → io_adapters/nil_adapter_test.rb} +0 -0
- data/test/{adapter_registry_test.rb → io_adapters/registry_test.rb} +0 -0
- data/test/{stringio_adapter_test.rb → io_adapters/stringio_adapter_test.rb} +0 -0
- data/test/{uploaded_file_adapter_test.rb → io_adapters/uploaded_file_adapter_test.rb} +0 -0
- data/test/paperclip_missing_attachment_styles_test.rb +10 -12
- data/test/paperclip_test.rb +4 -2
- data/test/storage/filesystem_test.rb +24 -16
- data/test/storage/fog_test.rb +14 -5
- data/test/storage/s3_live_test.rb +40 -12
- data/test/storage/s3_test.rb +13 -9
- data/test/style_test.rb +1 -1
- data/test/thumbnail_test.rb +7 -3
- data/test/validators/attachment_content_type_validator_test.rb +53 -1
- metadata +30 -28
- data/test/file_adapter_test.rb +0 -43
@@ -24,6 +24,58 @@ class AttachmentContentTypeValidatorTest < Test::Unit::TestCase
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
context "with :allow_nil option" do
|
28
|
+
context "as true" do
|
29
|
+
setup do
|
30
|
+
build_validator :content_type => "image/png", :allow_nil => true
|
31
|
+
@dummy.stubs(:avatar_content_type => nil)
|
32
|
+
@validator.validate(@dummy)
|
33
|
+
end
|
34
|
+
|
35
|
+
should "allow avatar_content_type as nil" do
|
36
|
+
assert @dummy.errors[:avatar_content_type].blank?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
context "as false" do
|
41
|
+
setup do
|
42
|
+
build_validator :content_type => "image/png", :allow_nil => false
|
43
|
+
@dummy.stubs(:avatar_content_type => nil)
|
44
|
+
@validator.validate(@dummy)
|
45
|
+
end
|
46
|
+
|
47
|
+
should "not allow avatar_content_type as nil" do
|
48
|
+
assert @dummy.errors[:avatar_content_type].present?
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
context "with :allow_blank option" do
|
54
|
+
context "as true" do
|
55
|
+
setup do
|
56
|
+
build_validator :content_type => "image/png", :allow_blank => true
|
57
|
+
@dummy.stubs(:avatar_content_type => "")
|
58
|
+
@validator.validate(@dummy)
|
59
|
+
end
|
60
|
+
|
61
|
+
should "allow avatar_content_type as blank" do
|
62
|
+
assert @dummy.errors[:avatar_content_type].blank?
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
context "as false" do
|
67
|
+
setup do
|
68
|
+
build_validator :content_type => "image/png", :allow_blank => false
|
69
|
+
@dummy.stubs(:avatar_content_type => "")
|
70
|
+
@validator.validate(@dummy)
|
71
|
+
end
|
72
|
+
|
73
|
+
should "not allow avatar_content_type as blank" do
|
74
|
+
assert @dummy.errors[:avatar_content_type].present?
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
27
79
|
context "with an allowed type" do
|
28
80
|
context "as a string" do
|
29
81
|
setup do
|
@@ -48,7 +100,7 @@ class AttachmentContentTypeValidatorTest < Test::Unit::TestCase
|
|
48
100
|
assert @dummy.errors[:avatar_content_type].blank?
|
49
101
|
end
|
50
102
|
end
|
51
|
-
|
103
|
+
|
52
104
|
context "as a list" do
|
53
105
|
setup do
|
54
106
|
build_validator :content_type => ["image/png", "image/jpg", "image/jpeg"]
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: paperclip
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 3.0.
|
4
|
+
version: 3.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-05-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activerecord
|
@@ -112,17 +112,17 @@ dependencies:
|
|
112
112
|
requirement: !ruby/object:Gem::Requirement
|
113
113
|
none: false
|
114
114
|
requirements:
|
115
|
-
- -
|
115
|
+
- - ! '>='
|
116
116
|
- !ruby/object:Gem::Version
|
117
|
-
version: 0
|
117
|
+
version: '0'
|
118
118
|
type: :development
|
119
119
|
prerelease: false
|
120
120
|
version_requirements: !ruby/object:Gem::Requirement
|
121
121
|
none: false
|
122
122
|
requirements:
|
123
|
-
- -
|
123
|
+
- - ! '>='
|
124
124
|
- !ruby/object:Gem::Version
|
125
|
-
version: 0
|
125
|
+
version: '0'
|
126
126
|
- !ruby/object:Gem::Dependency
|
127
127
|
name: mocha
|
128
128
|
requirement: !ruby/object:Gem::Requirement
|
@@ -144,17 +144,17 @@ dependencies:
|
|
144
144
|
requirement: !ruby/object:Gem::Requirement
|
145
145
|
none: false
|
146
146
|
requirements:
|
147
|
-
- -
|
147
|
+
- - ! '>='
|
148
148
|
- !ruby/object:Gem::Version
|
149
|
-
version:
|
149
|
+
version: '0'
|
150
150
|
type: :development
|
151
151
|
prerelease: false
|
152
152
|
version_requirements: !ruby/object:Gem::Requirement
|
153
153
|
none: false
|
154
154
|
requirements:
|
155
|
-
- -
|
155
|
+
- - ! '>='
|
156
156
|
- !ruby/object:Gem::Version
|
157
|
-
version:
|
157
|
+
version: '0'
|
158
158
|
- !ruby/object:Gem::Dependency
|
159
159
|
name: bourne
|
160
160
|
requirement: !ruby/object:Gem::Requirement
|
@@ -224,17 +224,17 @@ dependencies:
|
|
224
224
|
requirement: !ruby/object:Gem::Requirement
|
225
225
|
none: false
|
226
226
|
requirements:
|
227
|
-
- -
|
227
|
+
- - ! '>='
|
228
228
|
- !ruby/object:Gem::Version
|
229
|
-
version:
|
229
|
+
version: '0'
|
230
230
|
type: :development
|
231
231
|
prerelease: false
|
232
232
|
version_requirements: !ruby/object:Gem::Requirement
|
233
233
|
none: false
|
234
234
|
requirements:
|
235
|
-
- -
|
235
|
+
- - ! '>='
|
236
236
|
- !ruby/object:Gem::Version
|
237
|
-
version:
|
237
|
+
version: '0'
|
238
238
|
- !ruby/object:Gem::Dependency
|
239
239
|
name: capybara
|
240
240
|
requirement: !ruby/object:Gem::Requirement
|
@@ -379,6 +379,7 @@ files:
|
|
379
379
|
- LICENSE
|
380
380
|
- NEWS
|
381
381
|
- README.md
|
382
|
+
- RUNNING_TESTS.md
|
382
383
|
- Rakefile
|
383
384
|
- UPGRADING
|
384
385
|
- cucumber/paperclip_steps.rb
|
@@ -452,12 +453,9 @@ files:
|
|
452
453
|
- lib/tasks/paperclip.rake
|
453
454
|
- paperclip.gemspec
|
454
455
|
- shoulda_macros/paperclip.rb
|
455
|
-
- test/adapter_registry_test.rb
|
456
|
-
- test/attachment_adapter_test.rb
|
457
456
|
- test/attachment_options_test.rb
|
458
457
|
- test/attachment_test.rb
|
459
458
|
- test/database.yml
|
460
|
-
- test/file_adapter_test.rb
|
461
459
|
- test/fixtures/12k.png
|
462
460
|
- test/fixtures/50x50.png
|
463
461
|
- test/fixtures/5k.png
|
@@ -472,14 +470,19 @@ files:
|
|
472
470
|
- test/generator_test.rb
|
473
471
|
- test/geometry_test.rb
|
474
472
|
- test/helper.rb
|
475
|
-
- test/identity_adapter_test.rb
|
476
473
|
- test/integration_test.rb
|
477
474
|
- test/interpolations_test.rb
|
475
|
+
- test/io_adapters/attachment_adapter_test.rb
|
476
|
+
- test/io_adapters/file_adapter_test.rb
|
477
|
+
- test/io_adapters/identity_adapter_test.rb
|
478
|
+
- test/io_adapters/nil_adapter_test.rb
|
479
|
+
- test/io_adapters/registry_test.rb
|
480
|
+
- test/io_adapters/stringio_adapter_test.rb
|
481
|
+
- test/io_adapters/uploaded_file_adapter_test.rb
|
478
482
|
- test/matchers/have_attached_file_matcher_test.rb
|
479
483
|
- test/matchers/validate_attachment_content_type_matcher_test.rb
|
480
484
|
- test/matchers/validate_attachment_presence_matcher_test.rb
|
481
485
|
- test/matchers/validate_attachment_size_matcher_test.rb
|
482
|
-
- test/nil_adapter_test.rb
|
483
486
|
- test/paperclip_missing_attachment_styles_test.rb
|
484
487
|
- test/paperclip_test.rb
|
485
488
|
- test/processor_test.rb
|
@@ -488,14 +491,12 @@ files:
|
|
488
491
|
- test/storage/fog_test.rb
|
489
492
|
- test/storage/s3_live_test.rb
|
490
493
|
- test/storage/s3_test.rb
|
491
|
-
- test/stringio_adapter_test.rb
|
492
494
|
- test/style_test.rb
|
493
495
|
- test/support/mock_attachment.rb
|
494
496
|
- test/support/mock_interpolator.rb
|
495
497
|
- test/support/mock_model.rb
|
496
498
|
- test/support/mock_url_generator_builder.rb
|
497
499
|
- test/thumbnail_test.rb
|
498
|
-
- test/uploaded_file_adapter_test.rb
|
499
500
|
- test/url_generator_test.rb
|
500
501
|
- test/validators/attachment_content_type_validator_test.rb
|
501
502
|
- test/validators/attachment_presence_validator_test.rb
|
@@ -551,12 +552,9 @@ test_files:
|
|
551
552
|
- features/support/paths.rb
|
552
553
|
- features/support/rails.rb
|
553
554
|
- features/support/selectors.rb
|
554
|
-
- test/adapter_registry_test.rb
|
555
|
-
- test/attachment_adapter_test.rb
|
556
555
|
- test/attachment_options_test.rb
|
557
556
|
- test/attachment_test.rb
|
558
557
|
- test/database.yml
|
559
|
-
- test/file_adapter_test.rb
|
560
558
|
- test/fixtures/12k.png
|
561
559
|
- test/fixtures/50x50.png
|
562
560
|
- test/fixtures/5k.png
|
@@ -571,14 +569,19 @@ test_files:
|
|
571
569
|
- test/generator_test.rb
|
572
570
|
- test/geometry_test.rb
|
573
571
|
- test/helper.rb
|
574
|
-
- test/identity_adapter_test.rb
|
575
572
|
- test/integration_test.rb
|
576
573
|
- test/interpolations_test.rb
|
574
|
+
- test/io_adapters/attachment_adapter_test.rb
|
575
|
+
- test/io_adapters/file_adapter_test.rb
|
576
|
+
- test/io_adapters/identity_adapter_test.rb
|
577
|
+
- test/io_adapters/nil_adapter_test.rb
|
578
|
+
- test/io_adapters/registry_test.rb
|
579
|
+
- test/io_adapters/stringio_adapter_test.rb
|
580
|
+
- test/io_adapters/uploaded_file_adapter_test.rb
|
577
581
|
- test/matchers/have_attached_file_matcher_test.rb
|
578
582
|
- test/matchers/validate_attachment_content_type_matcher_test.rb
|
579
583
|
- test/matchers/validate_attachment_presence_matcher_test.rb
|
580
584
|
- test/matchers/validate_attachment_size_matcher_test.rb
|
581
|
-
- test/nil_adapter_test.rb
|
582
585
|
- test/paperclip_missing_attachment_styles_test.rb
|
583
586
|
- test/paperclip_test.rb
|
584
587
|
- test/processor_test.rb
|
@@ -587,16 +590,15 @@ test_files:
|
|
587
590
|
- test/storage/fog_test.rb
|
588
591
|
- test/storage/s3_live_test.rb
|
589
592
|
- test/storage/s3_test.rb
|
590
|
-
- test/stringio_adapter_test.rb
|
591
593
|
- test/style_test.rb
|
592
594
|
- test/support/mock_attachment.rb
|
593
595
|
- test/support/mock_interpolator.rb
|
594
596
|
- test/support/mock_model.rb
|
595
597
|
- test/support/mock_url_generator_builder.rb
|
596
598
|
- test/thumbnail_test.rb
|
597
|
-
- test/uploaded_file_adapter_test.rb
|
598
599
|
- test/url_generator_test.rb
|
599
600
|
- test/validators/attachment_content_type_validator_test.rb
|
600
601
|
- test/validators/attachment_presence_validator_test.rb
|
601
602
|
- test/validators/attachment_size_validator_test.rb
|
602
603
|
- test/validators_test.rb
|
604
|
+
has_rdoc:
|
data/test/file_adapter_test.rb
DELETED
@@ -1,43 +0,0 @@
|
|
1
|
-
require './test/helper'
|
2
|
-
|
3
|
-
class FileAdapterTest < Test::Unit::TestCase
|
4
|
-
context "a new instance" do
|
5
|
-
setup do
|
6
|
-
@file = File.new(fixture_file("5k.png"))
|
7
|
-
@file.binmode
|
8
|
-
@subject = Paperclip.io_adapters.for(@file)
|
9
|
-
end
|
10
|
-
|
11
|
-
should "get the right filename" do
|
12
|
-
assert_equal "5k.png", @subject.original_filename
|
13
|
-
end
|
14
|
-
|
15
|
-
should "force binmode on tempfile" do
|
16
|
-
assert @subject.instance_variable_get("@tempfile").binmode?
|
17
|
-
end
|
18
|
-
|
19
|
-
should "get the content type" do
|
20
|
-
assert_equal "image/png", @subject.content_type
|
21
|
-
end
|
22
|
-
|
23
|
-
should "get the file's size" do
|
24
|
-
assert_equal 4456, @subject.size
|
25
|
-
end
|
26
|
-
|
27
|
-
should "return false for a call to nil?" do
|
28
|
-
assert ! @subject.nil?
|
29
|
-
end
|
30
|
-
|
31
|
-
should "generate a MD5 hash of the contents" do
|
32
|
-
expected = Digest::MD5.file(@file.path).to_s
|
33
|
-
assert_equal expected, @subject.fingerprint
|
34
|
-
end
|
35
|
-
|
36
|
-
should "read the contents of the file" do
|
37
|
-
expected = @file.read
|
38
|
-
assert expected.length > 0
|
39
|
-
assert_equal expected, @subject.read
|
40
|
-
end
|
41
|
-
|
42
|
-
end
|
43
|
-
end
|