From b74fa53fac02b2eb30c669355a1ed8a670804fde Mon Sep 17 00:00:00 2001
From: Lavi Arzi <lavi.arzi@gmail.com>
Date: Mon, 10 Jul 2023 09:05:47 +0000
Subject: [PATCH] Replace single quote strings with double quote strings to
 enable the interpolated variables set in the previous commit

---
 app/serializers/lfs_file_lock_entity.rb       | 2 +-
 ee/app/helpers/path_locks_helper.rb           | 4 ++--
 ee/spec/helpers/path_locks_helper_spec.rb     | 4 ++--
 ee/spec/lib/gitlab/tree_summary_spec.rb       | 2 +-
 lib/gitlab/checks/diff_check.rb               | 2 +-
 spec/lib/gitlab/checks/diff_check_spec.rb     | 4 ++--
 spec/serializers/lfs_file_lock_entity_spec.rb | 2 +-
 7 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/app/serializers/lfs_file_lock_entity.rb b/app/serializers/lfs_file_lock_entity.rb
index 787d201d0a1af..dd109cba01553 100644
--- a/app/serializers/lfs_file_lock_entity.rb
+++ b/app/serializers/lfs_file_lock_entity.rb
@@ -8,6 +8,6 @@ class LfsFileLockEntity < Grape::Entity
   expose(:created_at, as: :locked_at) { |entity| entity.created_at.to_fs(:iso8601) }
 
   expose :owner do
-    expose(:name) { |entity| entity.user&.name }
+    expose(:name) { |entity| entity.user&.username }
   end
 end
diff --git a/ee/app/helpers/path_locks_helper.rb b/ee/app/helpers/path_locks_helper.rb
index f9ade343c2c90..b3e6cdee55b85 100644
--- a/ee/app/helpers/path_locks_helper.rb
+++ b/ee/app/helpers/path_locks_helper.rb
@@ -7,10 +7,10 @@ def can_unlock?(path_lock, current_user = @current_user)
 
   def text_label_for_lock(file_lock, path)
     if file_lock.path == path
-      "Locked by #{file_lock.user.name}"
+      "Locked by #{file_lock.user.username}"
     else
       # Nested lock
-      "#{file_lock.user.name} has a lock on \"#{file_lock.path}\""
+      "#{file_lock.user.username} has a lock on \"#{file_lock.path}\""
     end
   end
 end
diff --git a/ee/spec/helpers/path_locks_helper_spec.rb b/ee/spec/helpers/path_locks_helper_spec.rb
index cfa570d5478cc..6055dbb78cfd9 100644
--- a/ee/spec/helpers/path_locks_helper_spec.rb
+++ b/ee/spec/helpers/path_locks_helper_spec.rb
@@ -23,11 +23,11 @@
 
   describe '#text_label_for_lock' do
     it "return correct string for non-nested locks" do
-      expect(text_label_for_lock(path_lock, 'app')).to eq('Locked by John')
+      expect(text_label_for_lock(path_lock, 'app')).to eq("Locked by #{user.username}")
     end
 
     it "return correct string for nested locks" do
-      expect(text_label_for_lock(path_lock, 'app/models')).to eq('John has a lock on "app"')
+      expect(text_label_for_lock(path_lock, 'app/models')).to eq("#{user.username} has a lock on \"app\"")
     end
   end
 end
diff --git a/ee/spec/lib/gitlab/tree_summary_spec.rb b/ee/spec/lib/gitlab/tree_summary_spec.rb
index abd1455fb2e88..28a8044ad50c1 100644
--- a/ee/spec/lib/gitlab/tree_summary_spec.rb
+++ b/ee/spec/lib/gitlab/tree_summary_spec.rb
@@ -14,7 +14,7 @@
   describe '#summarize (entries)' do
     it 'includes path locks in entries' do
       is_expected.to contain_exactly(
-        a_hash_including(file_name: 'a.txt', lock_label: "Locked by #{path_lock.user.name}")
+        a_hash_including(file_name: 'a.txt', lock_label: "Locked by #{path_lock.user.username}")
       )
     end
   end
diff --git a/lib/gitlab/checks/diff_check.rb b/lib/gitlab/checks/diff_check.rb
index 1186b532baff8..bce4f969284a8 100644
--- a/lib/gitlab/checks/diff_check.rb
+++ b/lib/gitlab/checks/diff_check.rb
@@ -74,7 +74,7 @@ def lfs_file_locks_validation
           lfs_lock = project.lfs_file_locks.where(path: paths).where.not(user_id: user_access.user.id).take
 
           if lfs_lock
-            return "The path '#{lfs_lock.path}' is locked in Git LFS by #{lfs_lock.user.name}"
+            return "The path '#{lfs_lock.path}' is locked in Git LFS by #{lfs_lock.user.username}"
           end
         end
       end
diff --git a/spec/lib/gitlab/checks/diff_check_spec.rb b/spec/lib/gitlab/checks/diff_check_spec.rb
index dd467537a4f77..20c6ad8a6e899 100644
--- a/spec/lib/gitlab/checks/diff_check_spec.rb
+++ b/spec/lib/gitlab/checks/diff_check_spec.rb
@@ -94,7 +94,7 @@
 
         context 'when change is sent by a different user' do
           it 'raises an error if the user is not allowed to update the file' do
-            expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, "The path 'README' is locked in Git LFS by #{lock.user.name}")
+            expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, "The path 'README' is locked in Git LFS by #{lock.user.username}")
           end
         end
 
@@ -148,7 +148,7 @@
           end
 
           it "does raise an error" do
-            expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, "The path 'files/locked/baz.lfs' is locked in Git LFS by #{owner.name}")
+            expect { subject.validate! }.to raise_error(Gitlab::GitAccess::ForbiddenError, "The path 'files/locked/baz.lfs' is locked in Git LFS by #{owner.username}")
           end
         end
       end
diff --git a/spec/serializers/lfs_file_lock_entity_spec.rb b/spec/serializers/lfs_file_lock_entity_spec.rb
index 5869941c9201f..d0ff6fb60af0c 100644
--- a/spec/serializers/lfs_file_lock_entity_spec.rb
+++ b/spec/serializers/lfs_file_lock_entity_spec.rb
@@ -16,6 +16,6 @@
 
   it 'exposes the owner info' do
     expect(subject).to include(:owner)
-    expect(subject[:owner][:name]).to eq(user.name)
+    expect(subject[:owner][:name]).to eq(user.username)
   end
 end
-- 
GitLab