diff options
author | Stan Hu <stanhu@gmail.com> | 2015-06-21 08:26:37 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2015-07-01 07:01:59 -0700 |
commit | 9add3e6eb56bb8d8a9b8e4e105f7beec27e685d2 (patch) | |
tree | d0c34803d437a934aad6833d5b9733eda5192c45 /spec | |
parent | 3603edcff4d18ae0341213d7151325dda04aa9b3 (diff) | |
download | gitlab-ce-9add3e6eb56bb8d8a9b8e4e105f7beec27e685d2.tar.gz |
Extract the longest-matching ref from a commit path when multiple matches occur
Closes #1839
Diffstat (limited to 'spec')
-rw-r--r-- | spec/lib/extracts_path_spec.rb | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/spec/lib/extracts_path_spec.rb b/spec/lib/extracts_path_spec.rb index f077c80d478..4439775f612 100644 --- a/spec/lib/extracts_path_spec.rb +++ b/spec/lib/extracts_path_spec.rb @@ -10,7 +10,8 @@ describe ExtractsPath do before do @project = project - repo = double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0']) + repo = double(ref_names: ['master', 'foo/bar/baz', 'v1.0.0', 'v2.0.0', + 'release/app', 'release/app/v1.0.0']) allow(project).to receive(:repository).and_return(repo) allow(project).to receive(:path_with_namespace). and_return('gitlab/gitlab-ci') @@ -54,11 +55,17 @@ describe ExtractsPath do it "falls back to a primitive split for an invalid ref" do expect(extract_ref('stable')).to eq(['stable', '']) end + + it "extracts the longest matching ref" do + expect(extract_ref('release/app/v1.0.0/README.md')).to eq( + ['release/app/v1.0.0', 'README.md']) + end end context "with a path" do it "extracts a valid branch" do - expect(extract_ref('foo/bar/baz/CHANGELOG')).to eq(['foo/bar/baz', 'CHANGELOG']) + expect(extract_ref('foo/bar/baz/CHANGELOG')).to eq( + ['foo/bar/baz', 'CHANGELOG']) end it "extracts a valid tag" do |