diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 00:09:06 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-02-11 00:09:06 +0000 |
commit | a9104a50136e485c8dda7af37106332f9010a1e8 (patch) | |
tree | 26880b70033a0952d7801c9554b99cea827820dd /spec/models/repository_spec.rb | |
parent | 696b36294520f8a311586f99e838b6a61b1b3f32 (diff) | |
download | gitlab-ce-a9104a50136e485c8dda7af37106332f9010a1e8.tar.gz |
Add latest changes from gitlab-org/gitlab@master76926-follow-up-from-resolve-multi-selection-for-delete-on-registry-page
Diffstat (limited to 'spec/models/repository_spec.rb')
-rw-r--r-- | spec/models/repository_spec.rb | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index fdacfbe24d1..3d817065963 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -2781,6 +2781,45 @@ describe Repository do end end + describe '#create_from_bundle' do + let(:project) { create(:project) } + let(:repository) { project.repository } + let(:valid_bundle_path) { File.join(Dir.tmpdir, "repo-#{SecureRandom.hex}.bundle") } + let(:raw_repository) { repository.raw } + + before do + allow(raw_repository).to receive(:create_from_bundle).and_return({}) + end + + after do + FileUtils.rm_rf(valid_bundle_path) + end + + it 'calls out to the raw_repository to create a repo from bundle' do + expect(raw_repository).to receive(:create_from_bundle) + + repository.create_from_bundle(valid_bundle_path) + end + + it 'calls after_create' do + expect(repository).to receive(:after_create) + + repository.create_from_bundle(valid_bundle_path) + end + + context 'when exception is raised' do + before do + allow(raw_repository).to receive(:create_from_bundle).and_raise(::Gitlab::Git::BundleFile::InvalidBundleError) + end + + it 'after_create is not executed' do + expect(repository).not_to receive(:after_create) + + expect {repository.create_from_bundle(valid_bundle_path)}.to raise_error(::Gitlab::Git::BundleFile::InvalidBundleError) + end + end + end + describe "#blobs_metadata" do let_it_be(:project) { create(:project, :repository) } let(:repository) { project.repository } |