From 136ab73803850c10588b369862b1e5524849d31c Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Tue, 12 May 2015 17:58:29 -0400 Subject: Update CommitRange#to_reference to use full SHAs We only want them shortened by the filter, which calls to_s --- .../markdown/commit_range_reference_filter_spec.rb | 3 +-- spec/models/commit_range_spec.rb | 26 +++++++++++----------- 2 files changed, 14 insertions(+), 15 deletions(-) (limited to 'spec') diff --git a/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb b/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb index 7274cb309a0..1593088a094 100644 --- a/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb +++ b/spec/lib/gitlab/markdown/commit_range_reference_filter_spec.rb @@ -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| diff --git a/spec/models/commit_range_spec.rb b/spec/models/commit_range_spec.rb index 2d347a335a1..e7fb43ff335 100644 --- a/spec/models/commit_range_spec.rb +++ b/spec/models/commit_range_spec.rb @@ -1,6 +1,12 @@ 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}" -- cgit v1.2.1