Commit 4462d511 authored by Siddharth Asthana's avatar Siddharth Asthana Committed by Markus Koller

Fix Rails/SaveBang offenses

Changelog: other
parent 87734e88
......@@ -27,10 +27,3 @@ Rails/SaveBang:
- 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_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
before do
allow(Gitlab::ImportExport).to receive(:storage_path).and_return(export_path)
bundler.save
bundler.save # rubocop:disable Rails/SaveBang
end
after do
......
......@@ -30,7 +30,7 @@ RSpec.describe Gitlab::ImportExport::Saver do
it 'saves the repo using object storage' do
stub_uploads_object_storage(ImportExportUploader)
subject.save
subject.save # rubocop:disable Rails/SaveBang
expect(ImportExportUpload.find_by(project: project).export_file.url)
.to match(%r[\/uploads\/-\/system\/import_export_upload\/export_file.*])
......@@ -59,13 +59,13 @@ RSpec.describe Gitlab::ImportExport::Saver do
upload_bytes: anything
)).and_call_original
subject.save
subject.save # rubocop:disable Rails/SaveBang
end
it 'removes archive path and keeps base path untouched' do
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).to have_received(:rm_rf).with(archive_path)
......@@ -86,7 +86,7 @@ RSpec.describe Gitlab::ImportExport::Saver do
'correlation_id' => anything
)).and_call_original
subject.save
subject.save # rubocop:disable Rails/SaveBang
end
end
end
......@@ -70,7 +70,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoRestorer do
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(: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 }
before do
......
......@@ -38,7 +38,7 @@ RSpec.describe Gitlab::ImportExport::SnippetRepoSaver do
aggregate_failures do
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
end
......
......@@ -64,7 +64,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoRestorer do
let!(:snippet2) { create(:project_snippet, project: project, author: user) }
before do
exporter.save
exporter.save # rubocop:disable Rails/SaveBang
expect(File.exist?(bundle_path(snippet1))).to be true
expect(File.exist?(bundle_path(snippet2))).to be false
......@@ -78,7 +78,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoRestorer do
let!(:snippet2) { create(:project_snippet, :repository, project: project, author: user) }
before do
exporter.save
exporter.save # rubocop:disable Rails/SaveBang
expect(File.exist?(bundle_path(snippet1))).to be true
expect(File.exist?(bundle_path(snippet2))).to be true
......
......@@ -18,7 +18,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do
snippets_dir = ::Gitlab::ImportExport.snippets_repo_bundle_path(shared.export_path)
expect(Dir.exist?(snippets_dir)).to be_falsey
bundler.save
bundler.save # rubocop:disable Rails/SaveBang
expect(Dir.exist?(snippets_dir)).to be_truthy
end
......@@ -27,7 +27,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do
it 'does not perform any action' do
expect(Gitlab::ImportExport::SnippetRepoSaver).not_to receive(:new)
bundler.save
bundler.save # rubocop:disable Rails/SaveBang
end
end
......@@ -40,7 +40,7 @@ RSpec.describe Gitlab::ImportExport::SnippetsRepoSaver do
allow(Gitlab::ImportExport::SnippetRepoSaver).to receive(:new).and_return(service)
expect(service).to receive(:save).and_return(true).twice
bundler.save
bundler.save # rubocop:disable Rails/SaveBang
end
context 'when one snippet cannot be saved' do
......
......@@ -31,13 +31,13 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
let(:upload) { create(:upload, :issuable_upload, :with_file, model: project) }
it 'does not cause errors' do
manager.save
manager.save # rubocop:disable Rails/SaveBang
expect(shared.errors).to be_empty
end
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)
end
......@@ -56,7 +56,7 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
end
it 'excludes orphaned upload files' do
manager.save
manager.save # rubocop:disable Rails/SaveBang
expect(File).not_to exist(exported_orphan_path)
end
......@@ -68,7 +68,7 @@ RSpec.describe Gitlab::ImportExport::UploadsManager do
end
it 'does not cause errors' do
manager.save
manager.save # rubocop:disable Rails/SaveBang
expect(shared.errors).to be_empty
end
......@@ -84,7 +84,7 @@ RSpec.describe Gitlab::ImportExport::UploadsManager 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)
manager.save
manager.save # rubocop:disable Rails/SaveBang
expect(shared.errors).to be_empty
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