2017-08-17 22:00:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe AvatarUploader do
|
2018-05-09 12:01:36 +05:30
|
|
|
let(:model) { build_stubbed(:user) }
|
2018-03-17 18:26:18 +05:30
|
|
|
let(:uploader) { described_class.new(model, :avatar) }
|
|
|
|
let(:upload) { create(:upload, model: model) }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
subject { uploader }
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
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/]
|
2017-08-17 22:00:37 +05:30
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
context "object_store is REMOTE" do
|
|
|
|
before do
|
|
|
|
stub_uploads_object_storage
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
include_context 'with storage', described_class::Store::REMOTE
|
|
|
|
|
|
|
|
it_behaves_like 'builds correct paths',
|
|
|
|
store_dir: %r[user/avatar/],
|
|
|
|
upload_path: %r[user/avatar/]
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
|
2018-05-09 12:01:36 +05:30
|
|
|
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
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
2018-05-09 12:01:36 +05:30
|
|
|
|
|
|
|
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
|
2017-08-17 22:00:37 +05:30
|
|
|
end
|
|
|
|
end
|