summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/gitlab/utils.rb2
-rw-r--r--spec/config/settings_spec.rb6
-rw-r--r--spec/lib/gitlab/utils_spec.rb4
3 files changed, 6 insertions, 6 deletions
diff --git a/lib/gitlab/utils.rb b/lib/gitlab/utils.rb
index ad2efa6b4e1..41ed1dc5605 100644
--- a/lib/gitlab/utils.rb
+++ b/lib/gitlab/utils.rb
@@ -19,7 +19,7 @@ module Gitlab
def ensure_utf8_size(str, bytes:)
raise ArgumentError if str.empty? || bytes.negative?
- truncated = str.each_char.each_with_object(String.new) do |char, object|
+ truncated = str.each_char.each_with_object(+'') do |char, object|
if object.bytesize + char.bytesize > bytes
break object
else
diff --git a/spec/config/settings_spec.rb b/spec/config/settings_spec.rb
index fdbd0cb8990..f579ecacd3a 100644
--- a/spec/config/settings_spec.rb
+++ b/spec/config/settings_spec.rb
@@ -24,7 +24,7 @@ describe Settings do
it 'expands db key base secret to 12 bytes' do
expect(described_class.attr_encrypted_db_key_base_12)
- .to eq ('a' * 10) + ("\0" * 2)
+ .to eq(('a' * 10) + ("\0" * 2))
end
end
@@ -38,7 +38,7 @@ describe Settings do
it 'does not use more than 32 bytes' do
db_key_base = described_class.attr_encrypted_db_key_base_12
- expect(db_key_base).to eq ('❤' * 4)
+ expect(db_key_base).to eq('❤' * 4)
expect(db_key_base.bytesize).to eq 12
end
end
@@ -99,7 +99,7 @@ describe Settings do
it 'does not use more than 32 bytes' do
db_key_base = described_class.attr_encrypted_db_key_base_32
- expect(db_key_base).to eq ('❤' * 10) + ("\0" * 2)
+ expect(db_key_base).to eq(('❤' * 10) + ("\0" * 2))
expect(db_key_base.bytesize).to eq 32
end
end
diff --git a/spec/lib/gitlab/utils_spec.rb b/spec/lib/gitlab/utils_spec.rb
index 9927ad41108..7bf724bed6b 100644
--- a/spec/lib/gitlab/utils_spec.rb
+++ b/spec/lib/gitlab/utils_spec.rb
@@ -134,7 +134,7 @@ describe Gitlab::Utils do
transformed = described_class.ensure_utf8_size('a' * 10, bytes: 32)
expect(transformed.bytesize).to eq 32
- expect(transformed).to eq ('a' * 10) + ("\0" * 22)
+ expect(transformed).to eq(('a' * 10) + ("\0" * 22))
end
end
@@ -160,7 +160,7 @@ describe Gitlab::Utils do
it 'truncates string to 32 characters and backfills it if needed' do
transformed = described_class.ensure_utf8_size('❤' * 18, bytes: 32)
- expect(transformed).to eq ('❤' * 10) + ("\0" * 2)
+ expect(transformed).to eq(('❤' * 10) + ("\0" * 2))
expect(transformed.bytesize).to eq 32
end
end