diff options
author | Igor <idrozdov@gitlab.com> | 2019-04-12 16:25:17 +0300 |
---|---|---|
committer | Douwe Maan <douwe@gitlab.com> | 2019-04-12 16:25:17 +0300 |
commit | cfb94bca6f804c0dc762c5df2ed0a2c0d7c4c973 (patch) | |
tree | b052d191a73155b141ee77f93a4290e2523a7558 /app/models | |
parent | 004e8627218dc7621b5ff2e66b2b510c0afdcefc (diff) |
Fix grouping wiki pages by directory
If a page has the same name as a directory
the WikiPage#group_by_directory method can have
a wrong behaviour
This commit fixes it
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/wiki_page.rb | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index 909da4316d0..cd4c7895587 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -31,7 +31,9 @@ class WikiPage pages.each_with_object([]) do |page, grouped_pages| next grouped_pages << page unless page.directory.present? - directory = grouped_pages.find { |dir| dir.slug == page.directory } + directory = grouped_pages.find do |obj| + obj.is_a?(WikiDirectory) && obj.slug == page.directory + end next directory.pages << page if directory |