Commit dfb603d1 by Andrew Timberlake Committed by Jon Yurek

Added test for s3_headers option

parent 96c800e4
......@@ -125,6 +125,45 @@ class StorageTest < Test::Unit::TestCase
end
end
context "An attachment with S3 storage and specific s3 headers set" do
setup do
rebuild_model :storage => :s3,
:bucket => "testing",
:path => ":attachment/:style/:basename.:extension",
:s3_credentials => {
'access_key_id' => "12345",
'secret_access_key' => "54321"
},
:s3_headers => {'Cache-Control' => 'max-age=31557600'}
end
context "when assigned" do
setup do
@file = File.new(File.join(File.dirname(__FILE__), 'fixtures', '5k.png'), 'rb')
@dummy = Dummy.new
@dummy.avatar = @file
end
context "and saved" do
setup do
@s3_mock = stub
@bucket_mock = stub
RightAws::S3.expects(:new).with("12345", "54321", {}).returns(@s3_mock)
@s3_mock.expects(:bucket).with("testing", true, "public-read").returns(@bucket_mock)
@key_mock = stub
@bucket_mock.expects(:key).returns(@key_mock)
@key_mock.expects(:data=)
@key_mock.expects(:put).with(nil, 'public-read', 'Content-type' => 'image/png', 'Cache-Control' => 'max-age=31557600')
@dummy.save
end
should "succeed" do
assert true
end
end
end
end
unless ENV["S3_TEST_BUCKET"].blank?
context "Using S3 for real, an attachment with S3 storage" do
setup do
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment