Commit 309ca405 authored by Yorick Peterse's avatar Yorick Peterse

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.
parent f2caad24
......@@ -62,7 +62,7 @@ class CommitRange
def initialize(range_string, project)
@project = project
range_string.strip!
range_string = range_string.strip
unless range_string =~ /\A#{PATTERN}\z/
raise ArgumentError, "invalid CommitRange string format: #{range_string}"
......
......@@ -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}"
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment