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:
authorYorick Peterse <yorickpeterse@gmail.com>2016-05-02 19:15:25 +0300
committerYorick Peterse <yorickpeterse@gmail.com>2016-05-26 14:58:01 +0300
commit309ca405fa30e1eeaeaeddc0c8918e65c98ebbf7 (patch)
tree914eedab813d679087ba1c008f91b98577bcb42a /spec/models/commit_range_spec.rb
parentf2caad2467f318ec1359ee9b03509e831cde9d16 (diff)
Don't modify arguments in CommitRange#initialize
This method used to call strip! on input strings which will mess with the strings if they're re-used or frozen.
Diffstat (limited to 'spec/models/commit_range_spec.rb')
-rw-r--r--spec/models/commit_range_spec.rb10
1 files changed, 10 insertions, 0 deletions
diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb
index 9307d97e214..1cf51d8bab3 100644
--- a/spec/models/commit_range_spec.rb
+++ b/spec/models/commit_range_spec.rb
@@ -24,6 +24,16 @@ describe CommitRange, models: true do
expect { described_class.new("Foo", project) }.to raise_error(ArgumentError)
end
+ describe '#initialize' do
+ it 'does not modify strings in-place' do
+ input = "#{sha_from}...#{sha_to} "
+
+ described_class.new(input, project)
+
+ expect(input).to eq("#{sha_from}...#{sha_to} ")
+ end
+ end
+
describe '#to_s' do
it 'is correct for three-dot syntax' do
expect(range.to_s).to eq "#{full_sha_from}...#{full_sha_to}"