Commit 1c7c451a authored by Markus Koller's avatar Markus Koller

Merge branch 'issue_220040_17' into 'master'

Fix Rails/SaveBang offenses for spec/lib/gitlab/import_export/

See merge request gitlab-org/gitlab!75986
parents 416f756f 4462d511
...@@ -22,10 +22,3 @@ Rails/SaveBang: ...@@ -22,10 +22,3 @@ Rails/SaveBang:
- spec/lib/gitlab/import_export/project/relation_factory_spec.rb - spec/lib/gitlab/import_export/project/relation_factory_spec.rb
- spec/lib/gitlab/import_export/project/tree_restorer_spec.rb - spec/lib/gitlab/import_export/project/tree_restorer_spec.rb
- spec/lib/gitlab/import_export/project/tree_saver_spec.rb - spec/lib/gitlab/import_export/project/tree_saver_spec.rb
- spec/lib/gitlab/import_export/repo_restorer_spec.rb
- spec/lib/gitlab/import_export/saver_spec.rb
- spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb
- spec/lib/gitlab/import_export/snippet_repo_saver_spec.rb
- spec/lib/gitlab/import_export/snippets_repo_restorer_spec.rb
- spec/lib/gitlab/import_export/snippets_repo_saver_spec.rb
- spec/lib/gitlab/import_export/uploads_manager_spec.rb
...@@ -19,7 +19,7 @@ RSpec.describe Gitlab::ImportExport::RepoRestorer do ...@@ -19,7 +19,7 @@ RSpec.describe Gitlab::ImportExport::RepoRestorer do
before do before do
allow(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path) allow(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
bundler.save bundler.save # rubocop:disable Rails/SaveBang
end end
after do after do
......
...@@ -30,7 +30,7 @@ RSpec.describe Gitlab::ImportExport::Saver do ...@@ -30,7 +30,7 @@ RSpec.describe Gitlab::ImportExport::Saver do
it 'saves the repo using object storage' do it 'saves the repo using object storage' do
stub_uploads_object_storage(ImportExportUploader) stub_uploads_object_storage(ImportExportUploader)
subject.save subject.save # rubocop:disable Rails/SaveBang
expect(ImportExportUpload.find_by(project: project).export_file.url) expect(ImportExportUpload.find_by(project: project).export_file.url)
.to match(%r[\/uploads\/-\/system\/import_export_upload\/export_file.*]) .to match(%r[\/uploads\/-\/system\/import_export_upload\/export_file.*])
...@@ -59,13 +59,13 @@ RSpec.describe Gitlab::ImportExport::Saver do ...@@ -59,13 +59,13 @@ RSpec.describe Gitlab::ImportExport::Saver do
upload_bytes: anything upload_bytes: anything
)).and_call_original )).and_call_original
subject.save subject.save # rubocop:disable Rails/SaveBang
end end
it 'removes archive path and keeps base path untouched' do it 'removes archive path and keeps base path untouched' do
allow(shared).to receive(:archive_path).and_return(archive_path) allow(shared).to receive(:archive_path).and_return(archive_path)
subject.save subject.save # rubocop:disable Rails/SaveBang
expect(FileUtils).not_to have_received(:rm_rf).with(base_path) expect(FileUtils).not_to have_received(:rm_rf).with(base_path)
expect(FileUtils).to have_received(:rm_rf).with(archive_path) expect(FileUtils).to have_received(:rm_rf).with(archive_path)
...@@ -86,7 +86,7 @@ RSpec.describe Gitlab::ImportExport::Saver do ...@@ -86,7 +86,7 @@ RSpec.describe Gitlab::ImportExport::Saver do
'correlation_id' => anything 'correlation_id' => anything
)).and_call_original )).and_call_original
subject.save subject.save # rubocop:disable Rails/SaveBang
end end
end end
end end
...@@ -70,7 +70,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do ...@@ -70,7 +70,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do
let!(:snippet_with_repo) { create(:project_snippet, :repository, project: project, author: user) } let!(:snippet_with_repo) { create(:project_snippet, :repository, project: project, author: user) }
let(:bundle_path) { ::Gitlab::ImportExport.snippets_repo_bundle_path(shared.export_path) } let(:bundle_path) { ::Gitlab::ImportExport.snippets_repo_bundle_path(shared.export_path) }
let(:snippet_bundle_path) { File.join(bundle_path, "#{snippet_with_repo.hexdigest}.bundle") } let(:snippet_bundle_path) { File.join(bundle_path, "#{snippet_with_repo.hexdigest}.bundle") }
let(:result) { exporter.save } let(:result) { exporter.save } # rubocop:disable Rails/SaveBang
let(:repository) { snippet.repository } let(:repository) { snippet.repository }
before do before do
......
...@@ -38,7 +38,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoSaver do ...@@ -38,7 +38,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoSaver do
aggregate_failures do aggregate_failures do
expect(snippet.repository).not_to receive(:bundle_to_disk) expect(snippet.repository).not_to receive(:bundle_to_disk)
bundler.save bundler.save # rubocop:disable Rails/SaveBang
expect(Dir.empty?(bundle_path)).to be_truthy expect(Dir.empty?(bundle_path)).to be_truthy
end end
......
...@@ -64,7 +64,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoRestorer do ...@@ -64,7 +64,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoRestorer do
let!(:snippet2) { create(:project_snippet, project: project, author: user) } let!(:snippet2) { create(:project_snippet, project: project, author: user) }
before do before do
exporter.save exporter.save # rubocop:disable Rails/SaveBang
expect(File.exist?(bundle_path(snippet1))).to be true expect(File.exist?(bundle_path(snippet1))).to be true
expect(File.exist?(bundle_path(snippet2))).to be false expect(File.exist?(bundle_path(snippet2))).to be false
...@@ -78,7 +78,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoRestorer do ...@@ -78,7 +78,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoRestorer do
let!(:snippet2) { create(:project_snippet, :repository, project: project, author: user) } let!(:snippet2) { create(:project_snippet, :repository, project: project, author: user) }
before do before do
exporter.save exporter.save # rubocop:disable Rails/SaveBang
expect(File.exist?(bundle_path(snippet1))).to be true expect(File.exist?(bundle_path(snippet1))).to be true
expect(File.exist?(bundle_path(snippet2))).to be true expect(File.exist?(bundle_path(snippet2))).to be true
......
...@@ -18,7 +18,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do ...@@ -18,7 +18,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do
snippets_dir = ::Gitlab::ImportExport.snippets_repo_bundle_path(shared.export_path) snippets_dir = ::Gitlab::ImportExport.snippets_repo_bundle_path(shared.export_path)
expect(Dir.exist?(snippets_dir)).to be_falsey expect(Dir.exist?(snippets_dir)).to be_falsey
bundler.save bundler.save # rubocop:disable Rails/SaveBang
expect(Dir.exist?(snippets_dir)).to be_truthy expect(Dir.exist?(snippets_dir)).to be_truthy
end end
...@@ -27,7 +27,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do ...@@ -27,7 +27,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do
it 'does not perform any action' do it 'does not perform any action' do
expect(Gitlab::ImportExport::SnippetRepoSaver).not_to receive(:new) expect(Gitlab::ImportExport::SnippetRepoSaver).not_to receive(:new)
bundler.save bundler.save # rubocop:disable Rails/SaveBang
end end
end end
...@@ -40,7 +40,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do ...@@ -40,7 +40,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do
allow(Gitlab::ImportExport::SnippetRepoSaver).to receive(:new).and_return(service) allow(Gitlab::ImportExport::SnippetRepoSaver).to receive(:new).and_return(service)
expect(service).to receive(:save).and_return(true).twice expect(service).to receive(:save).and_return(true).twice
bundler.save bundler.save # rubocop:disable Rails/SaveBang
end end
context 'when one snippet cannot be saved' do context 'when one snippet cannot be saved' do
......
...@@ -31,13 +31,13 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do ...@@ -31,13 +31,13 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
let(:upload) { create(:upload, :issuable_upload, :with_file, model: project) } let(:upload) { create(:upload, :issuable_upload, :with_file, model: project) }
it 'does not cause errors' do it 'does not cause errors' do
manager.save manager.save # rubocop:disable Rails/SaveBang
expect(shared.errors).to be_empty expect(shared.errors).to be_empty
end end
it 'copies the file in the correct location when there is an upload' do it 'copies the file in the correct location when there is an upload' do
manager.save manager.save # rubocop:disable Rails/SaveBang
expect(File).to exist(exported_file_path) expect(File).to exist(exported_file_path)
end end
...@@ -56,7 +56,7 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do ...@@ -56,7 +56,7 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
end end
it 'excludes orphaned upload files' do it 'excludes orphaned upload files' do
manager.save manager.save # rubocop:disable Rails/SaveBang
expect(File).not_to exist(exported_orphan_path) expect(File).not_to exist(exported_orphan_path)
end end
...@@ -68,7 +68,7 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do ...@@ -68,7 +68,7 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
end end
it 'does not cause errors' do it 'does not cause errors' do
manager.save manager.save # rubocop:disable Rails/SaveBang
expect(shared.errors).to be_empty expect(shared.errors).to be_empty
end end
...@@ -84,7 +84,7 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do ...@@ -84,7 +84,7 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
it 'ignores problematic upload and logs exception' do it 'ignores problematic upload and logs exception' do
expect(Gitlab::ErrorTracking).to receive(:log_exception).with(instance_of(Errno::ENAMETOOLONG), project_id: project.id) expect(Gitlab::ErrorTracking).to receive(:log_exception).with(instance_of(Errno::ENAMETOOLONG), project_id: project.id)
manager.save manager.save # rubocop:disable Rails/SaveBang
expect(shared.errors).to be_empty expect(shared.errors).to be_empty
expect(File).not_to exist(exported_file_path) expect(File).not_to exist(exported_file_path)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment