summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRémy Coutable <remy@rymai.me>2017-09-07 19:31:40 +0200
committerRémy Coutable <remy@rymai.me>2017-09-07 19:31:40 +0200
commit09d323dece07c68db4d019f0c5b42061a76a8892 (patch)
tree4ac848b8686ae8bb454a2e6fe138e18b66be102a
parent4ae8e20c9c860e5d5d6a148e9f4ee0ae7b8c8946 (diff)
downloadgitlab-ce-09d323dece07c68db4d019f0c5b42061a76a8892.tar.gz
Fix a "Wrong number of arguments" error in TreeHelper#flatten_tree37569-fix-wrong-number-of-arguments-in-tree_helper-flatten_tree
Signed-off-by: Rémy Coutable <remy@rymai.me>
-rw-r--r--app/helpers/tree_helper.rb2
-rw-r--r--spec/features/projects/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb20
2 files changed, 21 insertions, 1 deletions
diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb
index 95dbdc8ec46..c4ea0f5ac53 100644
--- a/app/helpers/tree_helper.rb
+++ b/app/helpers/tree_helper.rb
@@ -104,7 +104,7 @@ module TreeHelper
subtree = Gitlab::Git::Tree.where(@repository, @commit.id, tree.path)
if subtree.count == 1 && subtree.first.dir?
- return tree_join(tree.name, flatten_tree(subtree.first))
+ return tree_join(tree.name, flatten_tree(root_path, subtree.first))
else
return tree.name
end
diff --git a/spec/features/projects/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb b/spec/features/projects/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb
new file mode 100644
index 00000000000..a17e65cc5b9
--- /dev/null
+++ b/spec/features/projects/user_browses_a_tree_with_a_folder_containing_only_a_folder.rb
@@ -0,0 +1,20 @@
+require 'spec_helper'
+
+# This is a regression test for https://gitlab.com/gitlab-org/gitlab-ce/issues/37569
+describe 'User browses a tree with a folder containing only a folder' do
+ let(:project) { create(:project, :empty_repo) }
+ let(:user) { project.creator }
+
+ before do
+ # We need to disable the tree.flat_path provided by Gitaly to reproduce the issue
+ allow(Gitlab::GitalyClient).to receive(:feature_enabled?).and_return(false)
+
+ project.repository.create_dir(user, 'foo/bar', branch_name: 'master', message: 'Add the foo/bar folder')
+ sign_in(user)
+ visit(project_tree_path(project, project.repository.root_ref))
+ end
+
+ it 'shows the nested folder on a single row' do
+ expect(page).to have_content('foo/bar')
+ end
+end