diff options
| author | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-09-11 10:39:36 +0000 |
|---|---|---|
| committer | Grzegorz Bizon <grzegorz@gitlab.com> | 2018-09-11 10:39:36 +0000 |
| commit | c56f2b96159afaf6f1e0831d0e7a756a40568cab (patch) | |
| tree | 9070e9f1d9b63733e7d0ecd57bd7aeca242bdc85 /spec/lib | |
| parent | b9ea4e35ac679a87ea16ca01a5f02bd96b3b16c3 (diff) | |
| parent | 678ceb257ef829377c197ef368ea8e1b7fce9c4e (diff) | |
| download | gitlab-ce-c56f2b96159afaf6f1e0831d0e7a756a40568cab.tar.gz | |
Merge branch '51318-project-export-broken-when-avatar-is-set' into 'master'
Resolve "Project export broken when avatar is set"
Closes #51318
See merge request gitlab-org/gitlab-ce!21649
Diffstat (limited to 'spec/lib')
| -rw-r--r-- | spec/lib/gitlab/import_export/avatar_restorer_spec.rb | 33 |
1 files changed, 23 insertions, 10 deletions
diff --git a/spec/lib/gitlab/import_export/avatar_restorer_spec.rb b/spec/lib/gitlab/import_export/avatar_restorer_spec.rb index 4897d604bc1..e44ff6bbcbd 100644 --- a/spec/lib/gitlab/import_export/avatar_restorer_spec.rb +++ b/spec/lib/gitlab/import_export/avatar_restorer_spec.rb @@ -6,22 +6,35 @@ describe Gitlab::ImportExport::AvatarRestorer do let(:shared) { project.import_export_shared } let(:project) { create(:project) } - before do - allow_any_instance_of(described_class).to receive(:avatar_export_file) - .and_return(uploaded_image_temp_path) - end - after do project.remove_avatar! end - it 'restores a project avatar' do - expect(described_class.new(project: project, shared: shared).restore).to be true + 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 end - it 'saves the avatar into the project' do - described_class.new(project: project, shared: shared).restore + 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") - expect(project.reload.avatar.file.exists?).to be true + expect(described_class.new(project: project, shared: shared).restore).to be true + end end end |
