gitlab-org--gitlab-foss/spec/uploaders/avatar_uploader_spec.rb

40 lines
1.2 KiB
Ruby
Raw Normal View History

2016-08-18 10:31:44 -04:00
require 'spec_helper'
describe AvatarUploader do
let(:model) { build_stubbed(:user) }
let(:uploader) { described_class.new(model, :avatar) }
let(:upload) { create(:upload, model: model) }
2016-08-18 10:31:44 -04:00
subject { uploader }
it_behaves_like 'builds correct paths',
store_dir: %r[uploads/-/system/user/avatar/],
upload_path: %r[uploads/-/system/user/avatar/],
absolute_path: %r[#{CarrierWave.root}/uploads/-/system/user/avatar/]
context "object_store is REMOTE" do
before do
stub_uploads_object_storage
2016-08-18 10:31:44 -04:00
end
include_context 'with storage', described_class::Store::REMOTE
it_behaves_like 'builds correct paths',
store_dir: %r[user/avatar/],
upload_path: %r[user/avatar/]
2016-08-18 10:31:44 -04:00
end
context "with a file" do
let(:project) { create(:project, :with_avatar) }
let(:uploader) { project.avatar }
let(:upload) { uploader.upload }
before do
stub_uploads_object_storage
2016-08-18 10:31:44 -04:00
end
it_behaves_like "migrates", to_store: described_class::Store::REMOTE
it_behaves_like "migrates", from_store: described_class::Store::REMOTE, to_store: described_class::Store::LOCAL
2016-08-18 10:31:44 -04:00
end
end