2015-01-10 15:37:48 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe TreeHelper do
|
|
|
|
describe 'flatten_tree' do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
|
2015-06-22 16:00:54 -04:00
|
|
|
before do
|
2015-06-22 16:06:04 -04:00
|
|
|
@repository = project.repository
|
|
|
|
@commit = project.commit("e56497bb")
|
2015-06-22 16:00:54 -04:00
|
|
|
end
|
2015-01-10 15:37:48 -05:00
|
|
|
|
|
|
|
context "on a directory containing more than one file/directory" do
|
|
|
|
let(:tree_item) { double(name: "files", path: "files") }
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "returns the directory name" do
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(flatten_tree(tree_item)).to match('files')
|
2015-01-10 15:37:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "on a directory containing only one directory" do
|
|
|
|
let(:tree_item) { double(name: "foo", path: "foo") }
|
|
|
|
|
2016-07-25 14:16:19 -04:00
|
|
|
it "returns the flattened path" do
|
2015-02-12 13:17:35 -05:00
|
|
|
expect(flatten_tree(tree_item)).to match('foo/bar')
|
2015-01-10 15:37:48 -05:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|