2015-04-26 12:48:37 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe TreeHelper do
|
|
|
|
describe 'flatten_tree' do
|
2017-08-17 22:00:37 +05:30
|
|
|
let(:project) { create(:project, :repository) }
|
2015-04-26 12:48:37 +05:30
|
|
|
|
2015-09-11 14:41:01 +05:30
|
|
|
before do
|
2015-04-26 12:48:37 +05:30
|
|
|
@repository = project.repository
|
2015-09-11 14:41:01 +05:30
|
|
|
@commit = project.commit("e56497bb")
|
|
|
|
end
|
2015-04-26 12:48:37 +05:30
|
|
|
|
|
|
|
context "on a directory containing more than one file/directory" do
|
|
|
|
let(:tree_item) { double(name: "files", path: "files") }
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it "returns the directory name" do
|
2015-04-26 12:48:37 +05:30
|
|
|
expect(flatten_tree(tree_item)).to match('files')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "on a directory containing only one directory" do
|
|
|
|
let(:tree_item) { double(name: "foo", path: "foo") }
|
|
|
|
|
2016-09-13 17:45:13 +05:30
|
|
|
it "returns the flattened path" do
|
2015-04-26 12:48:37 +05:30
|
|
|
expect(flatten_tree(tree_item)).to match('foo/bar')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|