paperclip 4.3.7 → 5.0.0.beta1
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.
- checksums.yaml +4 -4
- data/.travis.yml +13 -9
- data/Appraisals +22 -6
- data/CONTRIBUTING.md +6 -1
- data/Gemfile +2 -8
- data/LICENSE +1 -1
- data/NEWS +28 -37
- data/README.md +81 -63
- data/UPGRADING +9 -9
- data/features/basic_integration.feature +1 -0
- data/features/step_definitions/s3_steps.rb +6 -2
- data/gemfiles/{4.1.gemfile → 4.2.awsv2.0.gemfile} +4 -6
- data/gemfiles/4.2.awsv2.1.gemfile +17 -0
- data/gemfiles/{4.2.gemfile → 4.2.awsv2.gemfile} +1 -0
- data/gemfiles/5.0.awsv2.0.gemfile +17 -0
- data/gemfiles/5.0.awsv2.1.gemfile +17 -0
- data/gemfiles/{3.2.gemfile → 5.0.awsv2.gemfile} +7 -1
- data/lib/paperclip.rb +0 -2
- data/lib/paperclip/attachment.rb +9 -8
- data/lib/paperclip/attachment_registry.rb +2 -1
- data/lib/paperclip/callbacks.rb +8 -6
- data/lib/paperclip/glue.rb +1 -1
- data/lib/paperclip/has_attached_file.rb +7 -1
- data/lib/paperclip/io_adapters/uri_adapter.rb +11 -30
- data/lib/paperclip/schema.rb +1 -2
- data/lib/paperclip/storage/s3.rb +59 -35
- data/lib/paperclip/version.rb +1 -1
- data/paperclip.gemspec +11 -7
- data/spec/paperclip/attachment_registry_spec.rb +28 -0
- data/spec/paperclip/attachment_spec.rb +32 -6
- data/spec/paperclip/has_attached_file_spec.rb +24 -8
- data/spec/paperclip/integration_spec.rb +4 -3
- data/spec/paperclip/io_adapters/http_url_proxy_adapter_spec.rb +5 -8
- data/spec/paperclip/io_adapters/uri_adapter_spec.rb +6 -31
- data/spec/paperclip/media_type_spoof_detector_spec.rb +3 -12
- data/spec/paperclip/paperclip_spec.rb +0 -32
- data/spec/paperclip/storage/s3_live_spec.rb +8 -4
- data/spec/paperclip/storage/s3_spec.rb +345 -165
- data/spec/paperclip/validators_spec.rb +2 -3
- data/spec/spec_helper.rb +3 -1
- data/spec/support/assertions.rb +7 -0
- data/spec/support/model_reconstruction.rb +9 -1
- data/spec/support/reporting.rb +11 -0
- metadata +45 -40
- data/lib/paperclip/deprecations.rb +0 -42
- data/lib/paperclip/locales/de.yml +0 -18
- data/lib/paperclip/locales/es.yml +0 -18
- data/lib/paperclip/locales/ja.yml +0 -18
- data/lib/paperclip/locales/pt-BR.yml +0 -18
- data/lib/paperclip/locales/zh-CN.yml +0 -18
- data/lib/paperclip/locales/zh-HK.yml +0 -18
- data/lib/paperclip/locales/zh-TW.yml +0 -18
- data/spec/paperclip/deprecations_spec.rb +0 -65
- data/spec/support/deprecations.rb +0 -9
- data/spec/support/rails_helpers.rb +0 -7
data/lib/paperclip/version.rb
CHANGED
data/paperclip.gemspec
CHANGED
@@ -17,21 +17,25 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
18
18
|
s.require_paths = ["lib"]
|
19
19
|
|
20
|
+
if File.exist?('UPGRADING')
|
21
|
+
s.post_install_message = File.read("UPGRADING")
|
22
|
+
end
|
23
|
+
|
20
24
|
s.requirements << "ImageMagick"
|
21
|
-
s.required_ruby_version = ">= 1.
|
25
|
+
s.required_ruby_version = ">= 2.1.0"
|
22
26
|
|
23
|
-
s.add_dependency('activemodel', '>=
|
24
|
-
s.add_dependency('activesupport', '>=
|
27
|
+
s.add_dependency('activemodel', '>= 4.2.0')
|
28
|
+
s.add_dependency('activesupport', '>= 4.2.0')
|
25
29
|
s.add_dependency('cocaine', '~> 0.5.5')
|
26
30
|
s.add_dependency('mime-types')
|
27
|
-
s.add_dependency('mimemagic', '0.3.0')
|
31
|
+
s.add_dependency('mimemagic', '~> 0.3.0')
|
28
32
|
|
29
|
-
s.add_development_dependency('activerecord', '>=
|
33
|
+
s.add_development_dependency('activerecord', '>= 4.2.0')
|
30
34
|
s.add_development_dependency('shoulda')
|
31
35
|
s.add_development_dependency('rspec', '~> 3.0')
|
32
36
|
s.add_development_dependency('appraisal')
|
33
37
|
s.add_development_dependency('mocha')
|
34
|
-
s.add_development_dependency('aws-sdk', '>=
|
38
|
+
s.add_development_dependency('aws-sdk', '>= 2.0.33', '< 3.0')
|
35
39
|
s.add_development_dependency('bourne')
|
36
40
|
s.add_development_dependency('cucumber', '~> 1.3.18')
|
37
41
|
s.add_development_dependency('aruba', '~> 0.9.0')
|
@@ -45,7 +49,7 @@ Gem::Specification.new do |s|
|
|
45
49
|
s.add_development_dependency('rake')
|
46
50
|
s.add_development_dependency('fakeweb')
|
47
51
|
s.add_development_dependency('railties')
|
48
|
-
s.add_development_dependency('actionmailer', '>=
|
52
|
+
s.add_development_dependency('actionmailer', '>= 4.2.0')
|
49
53
|
s.add_development_dependency('generator_spec')
|
50
54
|
s.add_development_dependency('timecop')
|
51
55
|
end
|
@@ -111,6 +111,34 @@ describe 'Attachment Registry' do
|
|
111
111
|
|
112
112
|
assert_equal expected_definitions, definitions
|
113
113
|
end
|
114
|
+
|
115
|
+
it 'allows subclasses to override attachment defitions' do
|
116
|
+
foo_definitions = { avatar: { yo: "greeting" } }
|
117
|
+
bar_definitions = { avatar: { yo: "hello" } }
|
118
|
+
|
119
|
+
expected_definitions = {
|
120
|
+
avatar: {
|
121
|
+
yo: "hello"
|
122
|
+
}
|
123
|
+
}
|
124
|
+
|
125
|
+
foo = Class.new
|
126
|
+
bar = Class.new(foo)
|
127
|
+
Paperclip::AttachmentRegistry.register(
|
128
|
+
foo,
|
129
|
+
:avatar,
|
130
|
+
foo_definitions[:avatar]
|
131
|
+
)
|
132
|
+
Paperclip::AttachmentRegistry.register(
|
133
|
+
bar,
|
134
|
+
:avatar,
|
135
|
+
bar_definitions[:avatar]
|
136
|
+
)
|
137
|
+
|
138
|
+
definitions = Paperclip::AttachmentRegistry.definitions_for(bar)
|
139
|
+
|
140
|
+
assert_equal expected_definitions, definitions
|
141
|
+
end
|
114
142
|
end
|
115
143
|
|
116
144
|
context '.clear' do
|
@@ -700,9 +700,6 @@ describe Paperclip::Attachment do
|
|
700
700
|
|
701
701
|
context "when assigned" do
|
702
702
|
it "calls #make on all specified processors" do
|
703
|
-
Paperclip::Thumbnail.stubs(:make).with(any_parameters).returns(@file)
|
704
|
-
Paperclip::Test.stubs(:make).with(any_parameters).returns(@file)
|
705
|
-
|
706
703
|
@dummy.avatar = @file
|
707
704
|
|
708
705
|
expect(Paperclip::Thumbnail).to have_received(:make)
|
@@ -717,7 +714,6 @@ describe Paperclip::Attachment do
|
|
717
714
|
convert_options: "",
|
718
715
|
source_file_options: ""
|
719
716
|
})
|
720
|
-
Paperclip::Thumbnail.stubs(:make).returns(@file)
|
721
717
|
|
722
718
|
@dummy.avatar = @file
|
723
719
|
|
@@ -725,12 +721,36 @@ describe Paperclip::Attachment do
|
|
725
721
|
end
|
726
722
|
|
727
723
|
it "calls #make with attachment passed as third argument" do
|
728
|
-
Paperclip::Test.expects(:make).returns(@file)
|
729
|
-
|
730
724
|
@dummy.avatar = @file
|
731
725
|
|
732
726
|
expect(Paperclip::Test).to have_received(:make).with(anything, anything, @dummy.avatar)
|
733
727
|
end
|
728
|
+
|
729
|
+
it "calls #make and unlinks intermediary files afterward" do
|
730
|
+
@dummy.avatar.expects(:unlink_files).with([@file, @file])
|
731
|
+
|
732
|
+
@dummy.avatar = @file
|
733
|
+
end
|
734
|
+
end
|
735
|
+
end
|
736
|
+
|
737
|
+
context "An attachment with a processor that returns original file" do
|
738
|
+
before do
|
739
|
+
class Paperclip::Test < Paperclip::Processor
|
740
|
+
def make; @file; end
|
741
|
+
end
|
742
|
+
rebuild_model processors: [:test], styles: { once: "100x100" }
|
743
|
+
@file = StringIO.new("...")
|
744
|
+
@file.stubs(:close)
|
745
|
+
@dummy = Dummy.new
|
746
|
+
end
|
747
|
+
|
748
|
+
context "when assigned" do
|
749
|
+
it "#calls #make and doesn't unlink the original file" do
|
750
|
+
@dummy.avatar.expects(:unlink_files).with([])
|
751
|
+
|
752
|
+
@dummy.avatar = @file
|
753
|
+
end
|
734
754
|
end
|
735
755
|
end
|
736
756
|
|
@@ -1354,6 +1374,12 @@ describe Paperclip::Attachment do
|
|
1354
1374
|
end
|
1355
1375
|
|
1356
1376
|
it "does not calculate fingerprint" do
|
1377
|
+
Digest::MD5.stubs(:file)
|
1378
|
+
@dummy.avatar = @file
|
1379
|
+
expect(Digest::MD5).to have_received(:file).never
|
1380
|
+
end
|
1381
|
+
|
1382
|
+
it "does not assign fingerprint" do
|
1357
1383
|
@dummy.avatar = @file
|
1358
1384
|
assert_nil @dummy.avatar.fingerprint
|
1359
1385
|
end
|
@@ -38,6 +38,15 @@ describe Paperclip::HasAttachedFile do
|
|
38
38
|
assert_adding_attachment('avatar').defines_callback('after_commit')
|
39
39
|
end
|
40
40
|
|
41
|
+
context 'when the class does not allow after_commit callbacks' do
|
42
|
+
it 'defines an after_destroy callback' do
|
43
|
+
assert_adding_attachment(
|
44
|
+
'avatar',
|
45
|
+
unstub_methods: [:after_commit]
|
46
|
+
).defines_callback('after_destroy')
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
41
50
|
it 'defines the Paperclip-specific callbacks' do
|
42
51
|
assert_adding_attachment('avatar').defines_callback('define_paperclip_callbacks')
|
43
52
|
end
|
@@ -53,20 +62,26 @@ describe Paperclip::HasAttachedFile do
|
|
53
62
|
|
54
63
|
private
|
55
64
|
|
56
|
-
def assert_adding_attachment(attachment_name)
|
57
|
-
AttachmentAdder.new(attachment_name)
|
65
|
+
def assert_adding_attachment(attachment_name, options={})
|
66
|
+
AttachmentAdder.new(attachment_name, options)
|
58
67
|
end
|
59
68
|
|
60
69
|
class AttachmentAdder
|
61
70
|
include Mocha::API
|
62
71
|
include RSpec::Matchers
|
63
72
|
|
64
|
-
def initialize(attachment_name)
|
73
|
+
def initialize(attachment_name, options = {})
|
65
74
|
@attachment_name = attachment_name
|
75
|
+
@stubbed_class = stub_class
|
76
|
+
if options.present?
|
77
|
+
options[:unstub_methods].each do |method|
|
78
|
+
@stubbed_class.unstub(method)
|
79
|
+
end
|
80
|
+
end
|
66
81
|
end
|
67
82
|
|
68
83
|
def defines_method(method_name)
|
69
|
-
a_class =
|
84
|
+
a_class = @stubbed_class
|
70
85
|
|
71
86
|
Paperclip::HasAttachedFile.define_on(a_class, @attachment_name, {})
|
72
87
|
|
@@ -74,7 +89,7 @@ describe Paperclip::HasAttachedFile do
|
|
74
89
|
end
|
75
90
|
|
76
91
|
def defines_class_method(method_name)
|
77
|
-
a_class =
|
92
|
+
a_class = @stubbed_class
|
78
93
|
a_class.class.stubs(:define_method)
|
79
94
|
|
80
95
|
Paperclip::HasAttachedFile.define_on(a_class, @attachment_name, {})
|
@@ -83,7 +98,7 @@ describe Paperclip::HasAttachedFile do
|
|
83
98
|
end
|
84
99
|
|
85
100
|
def defines_validation
|
86
|
-
a_class =
|
101
|
+
a_class = @stubbed_class
|
87
102
|
|
88
103
|
Paperclip::HasAttachedFile.define_on(a_class, @attachment_name, {})
|
89
104
|
|
@@ -91,7 +106,7 @@ describe Paperclip::HasAttachedFile do
|
|
91
106
|
end
|
92
107
|
|
93
108
|
def registers_attachment
|
94
|
-
a_class =
|
109
|
+
a_class = @stubbed_class
|
95
110
|
Paperclip::AttachmentRegistry.stubs(:register)
|
96
111
|
|
97
112
|
Paperclip::HasAttachedFile.define_on(a_class, @attachment_name, {size: 1})
|
@@ -100,7 +115,7 @@ describe Paperclip::HasAttachedFile do
|
|
100
115
|
end
|
101
116
|
|
102
117
|
def defines_callback(callback_name)
|
103
|
-
a_class =
|
118
|
+
a_class = @stubbed_class
|
104
119
|
|
105
120
|
Paperclip::HasAttachedFile.define_on(a_class, @attachment_name, {})
|
106
121
|
|
@@ -132,6 +147,7 @@ describe Paperclip::HasAttachedFile do
|
|
132
147
|
after_save: nil,
|
133
148
|
before_destroy: nil,
|
134
149
|
after_commit: nil,
|
150
|
+
after_destroy: nil,
|
135
151
|
define_paperclip_callbacks: nil,
|
136
152
|
extend: nil,
|
137
153
|
name: 'Billy',
|
@@ -7,9 +7,10 @@ describe 'Paperclip' do
|
|
7
7
|
before do
|
8
8
|
rebuild_model
|
9
9
|
@file = File.new(fixture_file("5k.png"), 'rb')
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
# Deals with `Too many open files` error
|
11
|
+
Dummy.import 100.times.map { Dummy.new avatar: @file }
|
12
|
+
Dummy.import 100.times.map { Dummy.new avatar: @file }
|
13
|
+
Dummy.import 100.times.map { Dummy.new avatar: @file }
|
13
14
|
end
|
14
15
|
|
15
16
|
after { @file.close }
|
@@ -1,16 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Paperclip::HttpUrlProxyAdapter do
|
4
|
-
before do
|
5
|
-
@open_return = StringIO.new("xxx")
|
6
|
-
@open_return.stubs(:content_type).returns("image/png")
|
7
|
-
@open_return.stubs(:meta).returns({})
|
8
|
-
Paperclip::HttpUrlProxyAdapter.any_instance.
|
9
|
-
stubs(:download_content).returns(@open_return)
|
10
|
-
end
|
11
|
-
|
12
4
|
context "a new instance" do
|
13
5
|
before do
|
6
|
+
@open_return = StringIO.new("xxx")
|
7
|
+
@open_return.stubs(:content_type).returns("image/png")
|
8
|
+
Paperclip::HttpUrlProxyAdapter.any_instance.stubs(:download_content).returns(@open_return)
|
14
9
|
@url = "http://thoughtbot.com/images/thoughtbot-logo.png"
|
15
10
|
@subject = Paperclip.io_adapters.for(@url)
|
16
11
|
end
|
@@ -65,6 +60,7 @@ describe Paperclip::HttpUrlProxyAdapter do
|
|
65
60
|
|
66
61
|
context "a url with query params" do
|
67
62
|
before do
|
63
|
+
Paperclip::HttpUrlProxyAdapter.any_instance.stubs(:download_content).returns(StringIO.new("x"))
|
68
64
|
@url = "https://github.com/thoughtbot/paperclip?file=test"
|
69
65
|
@subject = Paperclip.io_adapters.for(@url)
|
70
66
|
end
|
@@ -80,6 +76,7 @@ describe Paperclip::HttpUrlProxyAdapter do
|
|
80
76
|
|
81
77
|
context "a url with restricted characters in the filename" do
|
82
78
|
before do
|
79
|
+
Paperclip::HttpUrlProxyAdapter.any_instance.stubs(:download_content).returns(StringIO.new("x"))
|
83
80
|
@url = "https://github.com/thoughtbot/paper:clip.jpg"
|
84
81
|
@subject = Paperclip.io_adapters.for(@url)
|
85
82
|
end
|
@@ -1,19 +1,11 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe Paperclip::UriAdapter do
|
4
|
-
let(:content_type) { "image/png" }
|
5
|
-
let(:meta) { {} }
|
6
|
-
|
7
|
-
before do
|
8
|
-
@open_return = StringIO.new("xxx")
|
9
|
-
@open_return.stubs(:content_type).returns(content_type)
|
10
|
-
@open_return.stubs(:meta).returns(meta)
|
11
|
-
Paperclip::UriAdapter.any_instance.
|
12
|
-
stubs(:download_content).returns(@open_return)
|
13
|
-
end
|
14
|
-
|
15
4
|
context "a new instance" do
|
16
5
|
before do
|
6
|
+
@open_return = StringIO.new("xxx")
|
7
|
+
@open_return.stubs(:content_type).returns("image/png")
|
8
|
+
Paperclip::UriAdapter.any_instance.stubs(:download_content).returns(@open_return)
|
17
9
|
@uri = URI.parse("http://thoughtbot.com/images/thoughtbot-logo.png")
|
18
10
|
@subject = Paperclip.io_adapters.for(@uri)
|
19
11
|
end
|
@@ -64,9 +56,8 @@ describe Paperclip::UriAdapter do
|
|
64
56
|
end
|
65
57
|
|
66
58
|
context "a directory index url" do
|
67
|
-
let(:content_type) { "text/html" }
|
68
|
-
|
69
59
|
before do
|
60
|
+
Paperclip::UriAdapter.any_instance.stubs(:download_content).returns(StringIO.new("xxx"))
|
70
61
|
@uri = URI.parse("http://thoughtbot.com")
|
71
62
|
@subject = Paperclip.io_adapters.for(@uri)
|
72
63
|
end
|
@@ -82,6 +73,7 @@ describe Paperclip::UriAdapter do
|
|
82
73
|
|
83
74
|
context "a url with query params" do
|
84
75
|
before do
|
76
|
+
Paperclip::UriAdapter.any_instance.stubs(:download_content).returns(StringIO.new("xxx"))
|
85
77
|
@uri = URI.parse("https://github.com/thoughtbot/paperclip?file=test")
|
86
78
|
@subject = Paperclip.io_adapters.for(@uri)
|
87
79
|
end
|
@@ -91,26 +83,9 @@ describe Paperclip::UriAdapter do
|
|
91
83
|
end
|
92
84
|
end
|
93
85
|
|
94
|
-
context "a url with content disposition headers" do
|
95
|
-
let(:file_name) { "test_document.pdf" }
|
96
|
-
let(:meta) do
|
97
|
-
{
|
98
|
-
"content-disposition" => "attachment; filename=\"#{file_name}\";",
|
99
|
-
}
|
100
|
-
end
|
101
|
-
|
102
|
-
before do
|
103
|
-
@uri = URI.parse("https://github.com/thoughtbot/paperclip?file=test")
|
104
|
-
@subject = Paperclip.io_adapters.for(@uri)
|
105
|
-
end
|
106
|
-
|
107
|
-
it "returns a file name" do
|
108
|
-
assert_equal file_name, @subject.original_filename
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
86
|
context "a url with restricted characters in the filename" do
|
113
87
|
before do
|
88
|
+
Paperclip::UriAdapter.any_instance.stubs(:download_content).returns(StringIO.new("xxx"))
|
114
89
|
@uri = URI.parse("https://github.com/thoughtbot/paper:clip.jpg")
|
115
90
|
@subject = Paperclip.io_adapters.for(@uri)
|
116
91
|
end
|
@@ -44,18 +44,9 @@ describe Paperclip::MediaTypeSpoofDetector do
|
|
44
44
|
end
|
45
45
|
end
|
46
46
|
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
it "rejects the file" do
|
52
|
-
assert spoofed?
|
53
|
-
end
|
54
|
-
|
55
|
-
it "logs info about the detected spoof" do
|
56
|
-
Paperclip.expects(:log).with('Content Type Spoof: Filename empty.html (image/jpg from Headers, ["text/html"] from Extension), content type discovered from file command: text/html. See documentation to allow this combination.')
|
57
|
-
spoofed?
|
58
|
-
end
|
47
|
+
it "rejects a file if named .html and is as HTML, but we're told JPG" do
|
48
|
+
file = File.open(fixture_file("empty.html"))
|
49
|
+
assert Paperclip::MediaTypeSpoofDetector.using(file, "empty.html", "image/jpg").spoofed?
|
59
50
|
end
|
60
51
|
|
61
52
|
it "does not reject if content_type is empty but otherwise checks out" do
|
@@ -109,7 +109,6 @@ describe Paperclip do
|
|
109
109
|
|
110
110
|
context "An ActiveRecord model with an 'avatar' attachment" do
|
111
111
|
before do
|
112
|
-
Paperclip::Deprecations.stubs(:check)
|
113
112
|
rebuild_model path: "tmp/:class/omg/:style.:extension"
|
114
113
|
@file = File.new(fixture_file("5k.png"), 'rb')
|
115
114
|
end
|
@@ -124,37 +123,6 @@ describe Paperclip do
|
|
124
123
|
end
|
125
124
|
end
|
126
125
|
|
127
|
-
if using_protected_attributes?
|
128
|
-
context "that is attr_protected" do
|
129
|
-
before do
|
130
|
-
Dummy.class_eval do
|
131
|
-
attr_protected :avatar
|
132
|
-
end
|
133
|
-
@dummy = Dummy.new
|
134
|
-
end
|
135
|
-
|
136
|
-
it "does not assign the avatar on mass-set" do
|
137
|
-
@dummy.attributes = { other: "I'm set!",
|
138
|
-
avatar: @file }
|
139
|
-
|
140
|
-
assert_equal "I'm set!", @dummy.other
|
141
|
-
assert ! @dummy.avatar?
|
142
|
-
end
|
143
|
-
|
144
|
-
it "allows assigment on normal set" do
|
145
|
-
@dummy.other = "I'm set!"
|
146
|
-
@dummy.avatar = @file
|
147
|
-
|
148
|
-
assert_equal "I'm set!", @dummy.other
|
149
|
-
assert @dummy.avatar?
|
150
|
-
end
|
151
|
-
end
|
152
|
-
end
|
153
|
-
|
154
|
-
it "calls Paperclip::Deprecations.check" do
|
155
|
-
expect(Paperclip::Deprecations).to have_received(:check)
|
156
|
-
end
|
157
|
-
|
158
126
|
context "with a subclass" do
|
159
127
|
before do
|
160
128
|
class ::SubDummy < Dummy; end
|
@@ -8,6 +8,7 @@ unless ENV["S3_BUCKET"].blank?
|
|
8
8
|
storage: :s3,
|
9
9
|
bucket: ENV["S3_BUCKET"],
|
10
10
|
path: ":class/:attachment/:id/:style.:extension",
|
11
|
+
s3_region: ENV["S3_REGION"],
|
11
12
|
s3_credentials: {
|
12
13
|
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
13
14
|
aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
@@ -45,6 +46,7 @@ unless ENV["S3_BUCKET"].blank?
|
|
45
46
|
storage: :s3,
|
46
47
|
bucket: ENV["S3_BUCKET"],
|
47
48
|
path: ":class/:attachment/:id/:style.:extension",
|
49
|
+
s3_region: ENV["S3_REGION"],
|
48
50
|
s3_credentials: {
|
49
51
|
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
50
52
|
aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
@@ -64,6 +66,7 @@ unless ENV["S3_BUCKET"].blank?
|
|
64
66
|
storage: :s3,
|
65
67
|
bucket: ENV["S3_BUCKET"],
|
66
68
|
path: ":class/:attachment/:id/:style.:extension",
|
69
|
+
s3_region: ENV["S3_REGION"],
|
67
70
|
s3_credentials: {
|
68
71
|
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
69
72
|
aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
@@ -105,6 +108,7 @@ unless ENV["S3_BUCKET"].blank?
|
|
105
108
|
rebuild_model styles: { thumb: "100x100", square: "32x32#" },
|
106
109
|
storage: :s3,
|
107
110
|
bucket: ENV["S3_BUCKET"],
|
111
|
+
s3_region: ENV["S3_REGION"],
|
108
112
|
s3_credentials: {
|
109
113
|
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
110
114
|
aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
@@ -136,7 +140,7 @@ unless ENV["S3_BUCKET"].blank?
|
|
136
140
|
it "is destroyable" do
|
137
141
|
url = @dummy.avatar.url
|
138
142
|
@dummy.destroy
|
139
|
-
|
143
|
+
assert_forbidden_response url
|
140
144
|
end
|
141
145
|
end
|
142
146
|
|
@@ -146,12 +150,12 @@ unless ENV["S3_BUCKET"].blank?
|
|
146
150
|
storage: :s3,
|
147
151
|
bucket: ENV["S3_BUCKET"],
|
148
152
|
path: ":class/:attachment/:id/:style.:extension",
|
153
|
+
s3_region: ENV["S3_REGION"],
|
149
154
|
s3_credentials: {
|
150
155
|
aws_access_key_id: ENV['AWS_ACCESS_KEY_ID'],
|
151
156
|
aws_secre_access_key: ENV['AWS_SECRET_ACCESS_KEY']
|
152
157
|
},
|
153
|
-
s3_server_side_encryption:
|
154
|
-
|
158
|
+
s3_server_side_encryption: "AES256"
|
155
159
|
Dummy.delete_all
|
156
160
|
@dummy = Dummy.new
|
157
161
|
end
|
@@ -173,7 +177,7 @@ unless ENV["S3_BUCKET"].blank?
|
|
173
177
|
end
|
174
178
|
|
175
179
|
it "is encrypted on S3" do
|
176
|
-
assert @dummy.avatar.s3_object.server_side_encryption ==
|
180
|
+
assert @dummy.avatar.s3_object.server_side_encryption == "AES256"
|
177
181
|
end
|
178
182
|
end
|
179
183
|
end
|