summaryrefslogtreecommitdiff
path: root/spec/helpers/tree_helper_spec.rb
diff options
context:
space:
mode:
Diffstat (limited to 'spec/helpers/tree_helper_spec.rb')
-rw-r--r--spec/helpers/tree_helper_spec.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/spec/helpers/tree_helper_spec.rb b/spec/helpers/tree_helper_spec.rb
new file mode 100644
index 00000000000..8271e00f41b
--- /dev/null
+++ b/spec/helpers/tree_helper_spec.rb
@@ -0,0 +1,28 @@
+require 'spec_helper'
+
+describe TreeHelper do
+ describe 'flatten_tree' do
+ let(:project) { create(:project) }
+
+ before {
+ @repository = project.repository
+ @commit = project.repository.commit("e56497bb")
+ }
+
+ 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
+ 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") }
+
+ it "should return the flattened path" do
+ expect(flatten_tree(tree_item)).to match('foo/bar')
+ end
+ end
+ end
+end