Commit 136ab738 authored by Robert Speicher's avatar Robert Speicher

Update CommitRange#to_reference to use full SHAs

We only want them shortened by the filter, which calls to_s
parent 9d032cdd
......@@ -61,11 +61,14 @@ class CommitRange
end
def to_reference(from_project = nil)
# Not using to_s because we want the full SHAs
reference = sha_from + notation + sha_to
if cross_project_reference?(from_project)
"#{project.to_reference}@#{to_s}"
else
to_s
reference = project.to_reference + '@' + reference
end
reference
end
# Returns a String for use in a link's title attribute
......
......@@ -9,8 +9,7 @@ module Gitlab::Markdown
let(:commit2) { project.commit("HEAD~2") }
it 'requires project context' do
expect { described_class.call('Commit Range 1c002d..d200c1', {}) }.
to raise_error(ArgumentError, /:project/)
expect { described_class.call('') }.to raise_error(ArgumentError, /:project/)
end
%w(pre code a style).each do |elem|
......
require 'spec_helper'
describe CommitRange do
describe 'modules' do
subject { described_class }
it { is_expected.to include_module(Referable) }
end
let(:sha_from) { 'f3f85602' }
let(:sha_to) { 'e86e1013' }
......@@ -11,10 +17,14 @@ describe CommitRange do
expect { described_class.new("Foo") }.to raise_error
end
describe 'modules' do
subject { described_class }
describe '#to_s' do
it 'is correct for three-dot syntax' do
expect(range.to_s).to eq "#{sha_from[0..7]}...#{sha_to[0..7]}"
end
it { is_expected.to include_module(Referable) }
it 'is correct for two-dot syntax' do
expect(range2.to_s).to eq "#{sha_from[0..7]}..#{sha_to[0..7]}"
end
end
describe '#to_reference' do
......@@ -34,16 +44,6 @@ describe CommitRange do
end
end
describe '#to_s' do
it 'is correct for three-dot syntax' do
expect(range.to_s).to eq "#{sha_from[0..7]}...#{sha_to[0..7]}"
end
it 'is correct for two-dot syntax' do
expect(range2.to_s).to eq "#{sha_from[0..7]}..#{sha_to[0..7]}"
end
end
describe '#reference_title' do
it 'returns the correct String for three-dot ranges' do
expect(range.reference_title).to eq "Commits #{sha_from} through #{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