2019-11-26 03:06:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-07-15 14:03:31 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-07-10 14:24:02 +00:00
|
|
|
describe Gitlab::ImportExport::AvatarSaver do
|
2018-03-05 19:53:40 +00:00
|
|
|
let(:shared) { project.import_export_shared }
|
2017-02-22 00:51:36 +00:00
|
|
|
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
|
2018-06-05 21:18:06 +00:00
|
|
|
let(:project_with_avatar) { create(:project, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) }
|
2017-08-02 19:55:11 +00:00
|
|
|
let(:project) { create(:project) }
|
2016-07-15 14:03:31 +00:00
|
|
|
|
|
|
|
before do
|
|
|
|
FileUtils.mkdir_p("#{shared.export_path}/avatar/")
|
2019-12-16 12:07:43 +00:00
|
|
|
allow_next_instance_of(Gitlab::ImportExport::Shared) do |instance|
|
|
|
|
allow(instance).to receive(:export_path).and_return(export_path)
|
|
|
|
end
|
2016-07-15 14:03:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
after do
|
|
|
|
FileUtils.rm_rf("#{shared.export_path}/avatar")
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'saves a project avatar' do
|
|
|
|
described_class.new(project: project_with_avatar, shared: shared).save
|
|
|
|
|
2018-08-29 13:41:56 +00:00
|
|
|
expect(File).to exist(Dir["#{shared.export_path}/avatar/**/dk.png"].first)
|
2016-07-15 14:03:31 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'is fine not to have an avatar' do
|
|
|
|
expect(described_class.new(project: project, shared: shared).save).to be true
|
|
|
|
end
|
|
|
|
end
|