discourse/spec/components/local_store_spec.rb

31 lines
831 B
Ruby
Raw Normal View History

2013-06-05 06:34:53 +08:00
require 'spec_helper'
require 'local_store'
describe LocalStore do
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) }
it 'returns the url of the uploaded file if successful' do
2013-06-05 06:34:53 +08:00
# prevent the tests from creating directories & files...
FileUtils.stubs(:mkdir_p)
File.stubs(:open)
# The Time needs to be frozen as it is used to generate a clean & unique name
Time.stubs(:now).returns(Time.utc(2013, 2, 17, 12, 0, 0, 0))
2013-06-15 17:52:40 +08:00
#
LocalStore.store_file(file, "", image_info, 1).should == '/uploads/default/1/253dc8edf9d4ada1.png'
2013-06-05 06:34:53 +08:00
end
end
end