From c8c260ed5e8b8c5455cc9136468f4b9e3b5e0b7c Mon Sep 17 00:00:00 2001
From: Javiera Tapia <jtapia@gitlab.com>
Date: Tue, 5 Mar 2024 15:44:44 +0000
Subject: [PATCH] Minor improvements in specs and documentation

---
 .../lib/gitlab/backup/cli/shell/pipeline.rb          |  2 +-
 .../lib/gitlab/backup/cli/utils/tar.rb               |  6 +-----
 .../spec/gitlab/backup/cli/shell/pipeline_spec.rb    |  2 +-
 spec/lib/backup/targets/files_spec.rb                | 12 +++++-------
 4 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/shell/pipeline.rb b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/shell/pipeline.rb
index 6a18c54ff5932..8da4065b707eb 100644
--- a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/shell/pipeline.rb
+++ b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/shell/pipeline.rb
@@ -8,7 +8,7 @@ class Pipeline
           # Result data structure from running a pipeline
           #
           # @attr [String] stderr
-          # @attr [Array<Process::Status>] status
+          # @attr [Array<Process::Status>] status_list
           # @attr [Float] duration
           Result = Struct.new(:stderr, :status_list, :duration, keyword_init: true)
 
diff --git a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/utils/tar.rb b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/utils/tar.rb
index ac74a3dbc43e3..afaf32357c42d 100644
--- a/gems/gitlab-backup-cli/lib/gitlab/backup/cli/utils/tar.rb
+++ b/gems/gitlab-backup-cli/lib/gitlab/backup/cli/utils/tar.rb
@@ -44,11 +44,7 @@ def pack_cmd(archive_file:, target_directory:, target:, excludes: [])
 
             # Ensure single target or multiple targets are converted to string before adding to args,
             # to avoid type conversion errors with Pathname
-            if target.respond_to?(:map)
-              tar_args += target.map(&:to_s)
-            else
-              tar_args << target.to_s
-            end
+            tar_args += Array(target).map(&:to_s)
 
             Shell::Command.new(cmd, *tar_args)
           end
diff --git a/gems/gitlab-backup-cli/spec/gitlab/backup/cli/shell/pipeline_spec.rb b/gems/gitlab-backup-cli/spec/gitlab/backup/cli/shell/pipeline_spec.rb
index ad2837af557c7..d150d6b4af04e 100644
--- a/gems/gitlab-backup-cli/spec/gitlab/backup/cli/shell/pipeline_spec.rb
+++ b/gems/gitlab-backup-cli/spec/gitlab/backup/cli/shell/pipeline_spec.rb
@@ -12,7 +12,7 @@
   it { respond_to :shell_commands }
 
   describe '#initialize' do
-    it 'accept single argument' do
+    it 'accepts a single argument' do
       expect { pipeline.new(printf_command) }.not_to raise_exception
     end
 
diff --git a/spec/lib/backup/targets/files_spec.rb b/spec/lib/backup/targets/files_spec.rb
index 9fd09a0e5484c..ad82fd4f22429 100644
--- a/spec/lib/backup/targets/files_spec.rb
+++ b/spec/lib/backup/targets/files_spec.rb
@@ -12,18 +12,17 @@
   let(:status_1) { instance_double(Process::Status, success?: false, exitstatus: 1) }
   let(:pipeline_status_success) { Gitlab::Backup::Cli::Shell::Pipeline::Result.new(status_list: [status_0, status_0]) }
   let(:pipeline_status_failed) { Gitlab::Backup::Cli::Shell::Pipeline::Result.new(status_list: [status_1, status_1]) }
-  let(:restore_target) { File.realpath(Dir.mktmpdir('files-target-restore')) }
+  let(:tmp_backup_restore_dir) { Dir.mktmpdir('files-target-restore') }
+  let(:restore_target) { File.realpath(tmp_backup_restore_dir) }
   let(:backup_target) do
-    tmpdir = Dir.mktmpdir('files-target-backup')
-
     %w[@pages.tmp lost+found @hashed].each do |folder|
-      path = Pathname(tmpdir).join(folder, 'something', 'else')
+      path = Pathname(tmp_backup_restore_dir).join(folder, 'something', 'else')
 
       FileUtils.mkdir_p(path)
       FileUtils.touch(path.join('artifacts.zip'))
     end
 
-    File.realpath(tmpdir)
+    File.realpath(tmp_backup_restore_dir)
   end
 
   before do
@@ -36,8 +35,7 @@
   end
 
   after do
-    FileUtils.rm_rf(restore_target)
-    FileUtils.rm_rf(backup_target)
+    FileUtils.rm_rf([restore_target, backup_target], secure: true)
   end
 
   describe '#restore' do
-- 
GitLab