debian-mirror-gitlab/spec/lib/gitlab/import_export/avatar_restorer_spec.rb

41 lines
1.1 KiB
Ruby
Raw Normal View History

2016-08-24 12:49:21 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Gitlab::ImportExport::AvatarRestorer do
2017-08-17 22:00:37 +05:30
include UploadHelpers
2018-03-27 19:54:05 +05:30
let(:shared) { project.import_export_shared }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2016-08-24 12:49:21 +05:30
after do
project.remove_avatar!
end
2018-11-20 20:47:30 +05:30
context 'with avatar' do
before do
allow_any_instance_of(described_class).to receive(:avatar_export_file)
.and_return(uploaded_image_temp_path)
end
it 'restores a project avatar' do
expect(described_class.new(project: project, shared: shared).restore).to be true
end
it 'saves the avatar into the project' do
described_class.new(project: project, shared: shared).restore
expect(project.reload.avatar.file.exists?).to be true
end
2016-08-24 12:49:21 +05:30
end
2018-11-20 20:47:30 +05:30
it 'does not break if there is just a directory' do
Dir.mktmpdir do |tmpdir|
FileUtils.mkdir_p("#{tmpdir}/a/b")
allow_any_instance_of(described_class).to receive(:avatar_export_path)
.and_return("#{tmpdir}/a")
2016-08-24 12:49:21 +05:30
2018-11-20 20:47:30 +05:30
expect(described_class.new(project: project, shared: shared).restore).to be true
end
2016-08-24 12:49:21 +05:30
end
end