Commit b173fe21 authored by Siddharth Asthana's avatar Siddharth Asthana Committed by Markus Koller

Fix Rails/SaveBang offenses

Changelog: other
parent 053b7006
......@@ -15,10 +15,3 @@ Rails/SaveBang:
- spec/lib/gitlab/database/custom_structure_spec.rb
- spec/lib/gitlab/database/partitioning_migration_helpers/table_management_helpers_spec.rb
- spec/lib/gitlab/database_importers/self_monitoring/project/create_service_spec.rb
- spec/lib/gitlab/import_export/importer_spec.rb
- spec/lib/gitlab/import_export/lfs_restorer_spec.rb
- spec/lib/gitlab/import_export/lfs_saver_spec.rb
- spec/lib/gitlab/import_export/members_mapper_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_saver_spec.rb
......@@ -17,7 +17,7 @@ RSpec.describe Gitlab::ImportExport::Importer do
stub_uploads_object_storage(FileUploader)
FileUtils.mkdir_p(shared.export_path)
ImportExportUpload.create(project: project, import_file: import_file)
ImportExportUpload.create!(project: project, import_file: import_file)
allow(FileUtils).to receive(:rm_rf).and_call_original
end
......
......@@ -36,7 +36,7 @@ RSpec.describe Gitlab::ImportExport::LfsRestorer do
)
end
saver.save
saver.save # rubocop:disable Rails/SaveBang
project.lfs_objects.delete_all
end
......@@ -81,7 +81,7 @@ RSpec.describe Gitlab::ImportExport::LfsRestorer do
context 'when there is not an existing `LfsObject`' do
before do
lfs_object.destroy
lfs_object.destroy!
end
it 'creates a new lfs object' do
......
......@@ -34,13 +34,13 @@ RSpec.describe Gitlab::ImportExport::LfsSaver do
end
it 'does not cause errors' do
saver.save
saver.save # rubocop:disable Rails/SaveBang
expect(shared.errors).to be_empty
end
it 'copies the file in the correct location when there is an lfs object' do
saver.save
saver.save # rubocop:disable Rails/SaveBang
expect(File).to exist("#{shared.export_path}/lfs-objects/#{lfs_object.oid}")
end
......@@ -61,7 +61,7 @@ RSpec.describe Gitlab::ImportExport::LfsSaver do
end
it 'saves a json file correctly' do
saver.save
saver.save # rubocop:disable Rails/SaveBang
expect(File.exist?(lfs_json_file)).to eq(true)
expect(lfs_json).to eq(
......@@ -96,7 +96,7 @@ RSpec.describe Gitlab::ImportExport::LfsSaver do
expect(fake_uri).to receive(:open).and_return(StringIO.new('LFS file content'))
expect(URI).to receive(:parse).with('http://my-object-storage.local').and_return(fake_uri)
saver.save
saver.save # rubocop:disable Rails/SaveBang
expect(File.read(exported_file_path)).to eq('LFS file content')
end
......
......@@ -243,7 +243,6 @@ RSpec.describe Gitlab::ImportExport::MembersMapper do
before do
group.add_users([user, user2], GroupMember::DEVELOPER)
user.update(public_email: 'invite@test.com')
end
it 'maps the importer' do
......
......@@ -10,7 +10,7 @@ RSpec.describe Gitlab::ImportExport::Project::RelationFactory, :use_clean_rails_
let(:importer_user) { admin }
let(:excluded_keys) { [] }
let(:created_object) do
described_class.create(
described_class.create( # rubocop:disable Rails/SaveBang
relation_sym: relation_sym,
relation_hash: relation_hash,
relation_index: 1,
......
......@@ -880,7 +880,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeRestorer do
before do
group = create(:group, visibility_level: group_visibility)
group.add_users([user], GroupMember::MAINTAINER)
project.update(group: group)
project.update!(group: group)
end
context 'private group visibility' do
......
......@@ -36,7 +36,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
project_tree_saver = described_class.new(project: project, current_user: user, shared: shared)
project_tree_saver.save
project_tree_saver.save # rubocop:disable Rails/SaveBang
end
end
......@@ -305,14 +305,14 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
end
before do
user2.update(public_email: user2.email)
user2.update!(public_email: user2.email)
group.add_developer(user2)
end
context 'when has no permission' do
before do
group.add_developer(user)
project_tree_saver.save
project_tree_saver.save # rubocop:disable Rails/SaveBang
end
it 'does not export group members' do
......@@ -324,7 +324,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
before do
group.add_maintainer(user)
project_tree_saver.save
project_tree_saver.save # rubocop:disable Rails/SaveBang
end
it 'does not export group members' do
......@@ -336,7 +336,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
before do
group.add_owner(user)
project_tree_saver.save
project_tree_saver.save # rubocop:disable Rails/SaveBang
end
it 'exports group members as group owner' do
......@@ -348,7 +348,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
let(:user) { create(:admin) }
before do
project_tree_saver.save
project_tree_saver.save # rubocop:disable Rails/SaveBang
end
context 'when admin mode is enabled', :enable_admin_mode do
......@@ -376,7 +376,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
let(:relation_name) { :projects }
before do
project_tree_saver.save
project_tree_saver.save # rubocop:disable Rails/SaveBang
end
it { is_expected.to include({ 'description' => params[:description] }) }
......@@ -471,7 +471,7 @@ RSpec.describe Gitlab::ImportExport::Project::TreeSaver do
merge_request = create(:merge_request, source_project: project, milestone: milestone)
ci_build = create(:ci_build, project: project, when: nil)
ci_build.pipeline.update(project: project)
ci_build.pipeline.update!(project: project)
create(:commit_status, project: project, pipeline: ci_build.pipeline)
create(:milestone, project: project)
......
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