a8c62dfe5c
- Moves a duplicate `file_storage?` definition into the common `GitlabUploader` ancestor. - Get the `uploads` base directory from a class method rather than hard-coding it where it's needed. This will be used in a subsequent MR to store Uploads in the database. - Improves the specs for uploaders.
35 lines
796 B
Ruby
35 lines
796 B
Ruby
require 'spec_helper'
|
|
|
|
describe FileUploader do
|
|
let(:uploader) { described_class.new(build_stubbed(:project)) }
|
|
|
|
describe 'initialize' do
|
|
it 'generates a secret if none is provided' do
|
|
expect(SecureRandom).to receive(:hex).and_return('secret')
|
|
|
|
uploader = described_class.new(double)
|
|
|
|
expect(uploader.secret).to eq 'secret'
|
|
end
|
|
|
|
it 'accepts a secret parameter' do
|
|
expect(SecureRandom).not_to receive(:hex)
|
|
|
|
uploader = described_class.new(double, 'secret')
|
|
|
|
expect(uploader.secret).to eq 'secret'
|
|
end
|
|
end
|
|
|
|
describe '#move_to_cache' do
|
|
it 'is true' do
|
|
expect(uploader.move_to_cache).to eq(true)
|
|
end
|
|
end
|
|
|
|
describe '#move_to_store' do
|
|
it 'is true' do
|
|
expect(uploader.move_to_store).to eq(true)
|
|
end
|
|
end
|
|
end
|