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

32 lines
986 B
Ruby
Raw Normal View History

2020-01-01 13:55:28 +05:30
# frozen_string_literal: true
2016-08-24 12:49:21 +05:30
require 'spec_helper'
2017-09-10 17:25:29 +05:30
describe Gitlab::ImportExport::AvatarSaver do
2018-03-27 19:54:05 +05:30
let(:shared) { project.import_export_shared }
2017-08-17 22:00:37 +05:30
let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" }
2018-11-08 19:23:39 +05:30
let(:project_with_avatar) { create(:project, avatar: fixture_file_upload("spec/fixtures/dk.png", "image/png")) }
2017-09-10 17:25:29 +05:30
let(:project) { create(:project) }
2016-08-24 12:49:21 +05:30
before do
FileUtils.mkdir_p("#{shared.export_path}/avatar/")
2020-01-01 13:55:28 +05:30
allow_next_instance_of(Gitlab::ImportExport::Shared) do |instance|
allow(instance).to receive(:export_path).and_return(export_path)
end
2016-08-24 12:49:21 +05:30
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-11-20 20:47:30 +05:30
expect(File).to exist(Dir["#{shared.export_path}/avatar/**/dk.png"].first)
2016-08-24 12:49:21 +05:30
end
it 'is fine not to have an avatar' do
expect(described_class.new(project: project, shared: shared).save).to be true
end
end