Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
4462d511
Commit
4462d511
authored
Jan 26, 2022
by
Siddharth Asthana
Committed by
Markus Koller
Jan 26, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Rails/SaveBang offenses
Changelog: other
parent
87734e88
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
17 additions
and
24 deletions
+17
-24
.rubocop_todo/rails/save_bang.yml
.rubocop_todo/rails/save_bang.yml
+0
-7
spec/lib/gitlab/import_export/repo_restorer_spec.rb
spec/lib/gitlab/import_export/repo_restorer_spec.rb
+1
-1
spec/lib/gitlab/import_export/saver_spec.rb
spec/lib/gitlab/import_export/saver_spec.rb
+4
-4
spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb
spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb
+1
-1
spec/lib/gitlab/import_export/snippet_repo_saver_spec.rb
spec/lib/gitlab/import_export/snippet_repo_saver_spec.rb
+1
-1
spec/lib/gitlab/import_export/snippets_repo_restorer_spec.rb
spec/lib/gitlab/import_export/snippets_repo_restorer_spec.rb
+2
-2
spec/lib/gitlab/import_export/snippets_repo_saver_spec.rb
spec/lib/gitlab/import_export/snippets_repo_saver_spec.rb
+3
-3
spec/lib/gitlab/import_export/uploads_manager_spec.rb
spec/lib/gitlab/import_export/uploads_manager_spec.rb
+5
-5
No files found.
.rubocop_todo/rails/save_bang.yml
View file @
4462d511
...
@@ -27,10 +27,3 @@ Rails/SaveBang:
...
@@ -27,10 +27,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
spec/lib/gitlab/import_export/repo_restorer_spec.rb
View file @
4462d511
...
@@ -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
...
...
spec/lib/gitlab/import_export/saver_spec.rb
View file @
4462d511
...
@@ -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
spec/lib/gitlab/import_export/snippet_repo_restorer_spec.rb
View file @
4462d511
...
@@ -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
...
...
spec/lib/gitlab/import_export/snippet_repo_saver_spec.rb
View file @
4462d511
...
@@ -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
...
...
spec/lib/gitlab/import_export/snippets_repo_restorer_spec.rb
View file @
4462d511
...
@@ -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
...
...
spec/lib/gitlab/import_export/snippets_repo_saver_spec.rb
View file @
4462d511
...
@@ -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
...
...
spec/lib/gitlab/import_export/uploads_manager_spec.rb
View file @
4462d511
...
@@ -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
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment