2015-01-10 15:37:48 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe TreeHelper do
|
|
|
|
describe 'flatten_tree' do
|
|
|
|
let(:project) { create(:project) }
|
|
|
|
|
|
|
|
before {
|
|
|
|
@repository = project.repository
|
2015-01-10 23:07:34 -05:00
|
|
|
@commit = project.repository.commit("e56497bb")
|
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") }
|
|
|
|
|
|
|
|
it "should return 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") }
|
|
|
|
|
|
|
|
it "should return 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
|