diff options
author | Luke Duncalfe <lduncalfe@eml.cc> | 2019-07-16 06:31:44 +0300 |
---|---|---|
committer | Luke Duncalfe <lduncalfe@eml.cc> | 2019-09-06 05:18:45 +0300 |
commit | 55ad5423eea6281657e1f7c6630774934f1f26b9 (patch) | |
tree | df72e6ee436c1504e4bbb55b3e1474b84c81087f /spec | |
parent | 8e49c2338a4cc9664e5f8fe454077a7a4021240c (diff) |
CE-specific changes to allow design repo exports11090-project-export-design-repository-ce
https://gitlab.com/gitlab-org/gitlab-ee/issues/11090
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/gitlab/import_export/repo_saver_spec.rb | 12 | ||||
-rw-r--r-- | spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb | 12 | ||||
-rw-r--r-- | spec/models/repository_spec.rb | 16 | ||||
-rw-r--r-- | spec/services/projects/import_export/export_service_spec.rb | 21 |
4 files changed, 48 insertions, 13 deletions
diff --git a/spec/lib/gitlab/import_export/repo_saver_spec.rb b/spec/lib/gitlab/import_export/repo_saver_spec.rb index 5a646b4aac8..c3df371af43 100644 --- a/spec/lib/gitlab/import_export/repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/repo_saver_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe Gitlab::ImportExport::RepoSaver do describe 'bundle a project Git repo' do - let(:user) { create(:user) } - let!(:project) { create(:project, :public, name: 'searchable_project') } + set(:user) { create(:user) } + let!(:project) { create(:project, :repository) } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:shared) { project.import_export_shared } let(:bundler) { described_class.new(project: project, shared: shared) } @@ -20,5 +20,13 @@ describe Gitlab::ImportExport::RepoSaver do it 'bundles the repo successfully' do expect(bundler.save).to be true end + + context 'when the repo is empty' do + let!(:project) { create(:project) } + + it 'bundles the repo successfully' do + expect(bundler.save).to be true + end + end end end diff --git a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb index 441aa1defe6..249afbd23d1 100644 --- a/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb +++ b/spec/lib/gitlab/import_export/wiki_repo_saver_spec.rb @@ -2,8 +2,8 @@ require 'spec_helper' describe Gitlab::ImportExport::WikiRepoSaver do describe 'bundle a wiki Git repo' do - let(:user) { create(:user) } - let!(:project) { create(:project, :public, :wiki_repo, name: 'searchable_project') } + set(:user) { create(:user) } + let!(:project) { create(:project, :wiki_repo) } let(:export_path) { "#{Dir.tmpdir}/project_tree_saver_spec" } let(:shared) { project.import_export_shared } let(:wiki_bundler) { described_class.new(project: project, shared: shared) } @@ -23,5 +23,13 @@ describe Gitlab::ImportExport::WikiRepoSaver do it 'bundles the repo successfully' do expect(wiki_bundler.save).to be true end + + context 'when the repo is empty' do + let!(:project) { create(:project) } + + it 'bundles the repo successfully' do + expect(wiki_bundler.save).to be true + end + end end end diff --git a/spec/models/repository_spec.rb b/spec/models/repository_spec.rb index 419e1dc2459..b6de5e175dc 100644 --- a/spec/models/repository_spec.rb +++ b/spec/models/repository_spec.rb @@ -1075,7 +1075,7 @@ describe Repository do let(:ref) { 'refs/heads/master' } it 'returns nil' do - is_expected.to eq(nil) + is_expected.to be_nil end end @@ -1972,7 +1972,7 @@ describe Repository do it 'returns nil if repo does not exist' do allow(repository).to receive(:root_ref).and_raise(Gitlab::Git::Repository::NoRepository) - expect(repository.avatar).to eq(nil) + expect(repository.avatar).to be_nil end it 'returns the first avatar file found in the repository' do @@ -2623,6 +2623,10 @@ describe Repository do expect { repository.create_if_not_exists }.to change { repository.exists? }.from(false).to(true) end + it 'returns true' do + expect(repository.create_if_not_exists).to eq(true) + end + it 'calls out to the repository client to create a repo' do expect(repository.raw.gitaly_repository_client).to receive(:create_repository) @@ -2637,6 +2641,10 @@ describe Repository do repository.create_if_not_exists end + + it 'returns nil' do + expect(repository.create_if_not_exists).to be_nil + end end context 'when the repository exists but the cache is not up to date' do @@ -2648,6 +2656,10 @@ describe Repository do expect { repository.create_if_not_exists }.not_to raise_error end + + it 'returns nil' do + expect(repository.create_if_not_exists).to be_nil + end end end diff --git a/spec/services/projects/import_export/export_service_spec.rb b/spec/services/projects/import_export/export_service_spec.rb index 404bb55629a..146d656c909 100644 --- a/spec/services/projects/import_export/export_service_spec.rb +++ b/spec/services/projects/import_export/export_service_spec.rb @@ -35,20 +35,27 @@ describe Projects::ImportExport::ExportService do end it 'saves the repo' do + # This spec errors when run against the EE codebase as there will be a third repository + # saved (the EE-specific design repository). + # + # Instead, skip this test when run within EE. There is a spec for the EE-specific design repo + # in the corresponding EE spec. + skip if Gitlab.ee? + # once for the normal repo, once for the wiki expect(Gitlab::ImportExport::RepoSaver).to receive(:new).twice.and_call_original service.execute end - it 'saves the lfs objects' do - expect(Gitlab::ImportExport::LfsSaver).to receive(:new).and_call_original + it 'saves the wiki repo' do + expect(Gitlab::ImportExport::WikiRepoSaver).to receive(:new).and_call_original service.execute end - it 'saves the wiki repo' do - expect(Gitlab::ImportExport::WikiRepoSaver).to receive(:new).and_call_original + it 'saves the lfs objects' do + expect(Gitlab::ImportExport::LfsSaver).to receive(:new).and_call_original service.execute end @@ -98,9 +105,9 @@ describe Projects::ImportExport::ExportService do end end - context 'when saver services fail' do + context 'when saving services fail' do before do - allow(service).to receive(:save_services).and_return(false) + allow(service).to receive(:save_exporters).and_return(false) end after do @@ -122,7 +129,7 @@ describe Projects::ImportExport::ExportService do expect(Rails.logger).to receive(:error) end - it 'the after export strategy is not called' do + it 'does not call the export strategy' do expect(service).not_to receive(:execute_after_export_action) end end |