discourse/spec/components/s3_store_spec.rb

38 lines
951 B
Ruby
Raw Normal View History

2013-06-04 18:34:53 -04:00
require 'spec_helper'
require 'fog'
2013-07-16 18:06:47 -04:00
require 's3_store'
2013-06-04 18:34:53 -04:00
2013-07-16 18:06:47 -04:00
describe S3Store do
2013-06-04 18:34:53 -04:00
describe "store_file" do
let(:file) do
ActionDispatch::Http::UploadedFile.new({
filename: 'logo.png',
content_type: 'image/png',
tempfile: File.new("#{Rails.root}/spec/fixtures/images/logo.png")
})
end
let(:image_info) { FastImage.new(file) }
2013-06-15 05:52:40 -04:00
before(:each) do
SiteSetting.stubs(:s3_upload_bucket).returns("S3_Upload_Bucket")
2013-06-04 18:34:53 -04:00
SiteSetting.stubs(:s3_access_key_id).returns("s3_access_key_id")
SiteSetting.stubs(:s3_secret_access_key).returns("s3_secret_access_key")
Fog.mock!
end
it 'returns the url of the S3 upload if successful' do
# NOTE: s3 bucket's name are case sensitive so we can't use it as a subdomain...
2013-07-16 18:06:47 -04:00
S3Store.store_file(file, "SHA", 1).should == '//s3.amazonaws.com/S3_Upload_Bucket/1SHA.png'
2013-06-04 18:34:53 -04:00
end
after(:each) do
Fog.unmock!
end
end
end