Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGitLab Bot <gitlab-bot@gitlab.com>2023-06-07 23:51:20 +0300
committerGitLab Bot <gitlab-bot@gitlab.com>2023-06-07 23:51:20 +0300
commit3010dc9ecab0267dd17b82722a4c22c478ee9f07 (patch)
tree85f2c64d1e449cee42424ab6cda68396d18743d8
parent338041562770d6b88aec0e367f8378b4cdf5f918 (diff)
Add latest changes from gitlab-org/gitlab@16-0-stable-ee
-rw-r--r--lib/gitlab_settings/options.rb4
-rw-r--r--spec/lib/gitlab_settings/options_spec.rb14
2 files changed, 18 insertions, 0 deletions
diff --git a/lib/gitlab_settings/options.rb b/lib/gitlab_settings/options.rb
index 5bdac74c2f6..077c1aa944a 100644
--- a/lib/gitlab_settings/options.rb
+++ b/lib/gitlab_settings/options.rb
@@ -43,6 +43,10 @@ module GitlabSettings
end
alias_method :to_h, :to_hash
+ def dup
+ self.class.build(to_hash)
+ end
+
def merge(other)
self.class.build(to_hash.merge(other.deep_stringify_keys))
end
diff --git a/spec/lib/gitlab_settings/options_spec.rb b/spec/lib/gitlab_settings/options_spec.rb
index 4b57e91c2e1..23cb2180edd 100644
--- a/spec/lib/gitlab_settings/options_spec.rb
+++ b/spec/lib/gitlab_settings/options_spec.rb
@@ -81,6 +81,20 @@ RSpec.describe GitlabSettings::Options, :aggregate_failures, feature_category: :
end
end
+ describe '#dup' do
+ it 'returns a deep copy' do
+ new_options = options.dup
+ expect(options.to_hash).to eq('foo' => { 'bar' => 'baz' })
+ expect(new_options.to_hash).to eq(options.to_hash)
+
+ new_options['test'] = 1
+ new_options['foo']['bar'] = 'zzz'
+
+ expect(options.to_hash).to eq('foo' => { 'bar' => 'baz' })
+ expect(new_options.to_hash).to eq('test' => 1, 'foo' => { 'bar' => 'zzz' })
+ end
+ end
+
describe '#merge' do
it 'merges a hash to the existing options' do
expect(options.merge(more: 'configs').to_hash).to eq(