summaryrefslogtreecommitdiff
path: root/spec/models/concerns/uniquify_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/models/concerns/uniquify_spec.rb')
-rw-r--r--spec/models/concerns/uniquify_spec.rb9
1 files changed, 9 insertions, 0 deletions
diff --git a/spec/models/concerns/uniquify_spec.rb b/spec/models/concerns/uniquify_spec.rb
index 914730718e7..6cd2de6dcce 100644
--- a/spec/models/concerns/uniquify_spec.rb
+++ b/spec/models/concerns/uniquify_spec.rb
@@ -22,6 +22,15 @@ describe Uniquify do
expect(result).to eq('test_string2')
end
+ it 'allows to pass an initial value for the counter' do
+ start_counting_from = 2
+ uniquify = described_class.new(start_counting_from)
+
+ result = uniquify.string('test_string') { |s| s == 'test_string' }
+
+ expect(result).to eq('test_string2')
+ end
+
it 'allows passing in a base function that defines the location of the counter' do
result = uniquify.string(-> (counter) { "test_#{counter}_string" }) do |s|
s == 'test__string'