diff options
author | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-09-07 15:21:30 +0200 |
---|---|---|
committer | Kamil Trzcinski <ayufan@ayufan.eu> | 2017-09-07 15:21:30 +0200 |
commit | e5e0acfc4dd65503b89e652beca5b973141c4032 (patch) | |
tree | 3123b4f7b9fbde403b417417d452f78f9db0eb25 /spec/helpers | |
parent | 83c1bb688c9fff5c146dcc5fb74fe74c1d948d34 (diff) | |
parent | 62a5cc7134457d21bf3a68bfdb04e090cf0e6ecf (diff) | |
download | gitlab-ce-e5e0acfc4dd65503b89e652beca5b973141c4032.tar.gz |
Merge branch 'zj-auto-devops-table' of gitlab.com:zj/gitlab-ce into 37158-autodevops-banner
Diffstat (limited to 'spec/helpers')
-rw-r--r-- | spec/helpers/tree_helper_spec.rb | 26 |
1 files changed, 18 insertions, 8 deletions
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb index 9523d0f4aa6..d7b66e6f078 100644 --- a/spec/helpers/tree_helper_spec.rb +++ b/spec/helpers/tree_helper_spec.rb @@ -3,25 +3,35 @@ require 'spec_helper' describe TreeHelper do describe 'flatten_tree' do let(:project) { create(:project, :repository) } + let(:repository) { project.repository } + let(:sha) { 'ce369011c189f62c815f5971d096b26759bab0d1' } + let(:tree) { repository.tree(sha, 'files') } + let(:root_path) { 'files' } + let(:tree_item) { tree.entries.find { |entry| entry.path == path } } - before do - @repository = project.repository - @commit = project.commit("e56497bb") - end + subject { flatten_tree(root_path, tree_item) } context "on a directory containing more than one file/directory" do - let(:tree_item) { double(name: "files", path: "files") } + let(:path) { 'files/html' } it "returns the directory name" do - expect(flatten_tree(tree_item)).to match('files') + expect(subject).to match('html') end end context "on a directory containing only one directory" do - let(:tree_item) { double(name: "foo", path: "foo") } + let(:path) { 'files/flat' } it "returns the flattened path" do - expect(flatten_tree(tree_item)).to match('foo/bar') + expect(subject).to match('flat/path/correct') + end + + context "with a nested root path" do + let(:root_path) { 'files/flat' } + + it "returns the flattened path with the root path suffix removed" do + expect(subject).to match('path/correct') + end end end end |