Skip to content

Commit

Permalink
Merge branch '60906-fix-wiki-links' into 'master'
Browse files Browse the repository at this point in the history
Use wiki partial in search results

Closes #60906

See merge request gitlab-org/gitlab-ce!27634
  • Loading branch information
stanhu committed Apr 25, 2019
2 parents 34578f8 + d60d50d commit f04f690
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 3 deletions.
5 changes: 2 additions & 3 deletions app/views/search/_results.html.haml
Expand Up @@ -21,10 +21,9 @@
- if @scope == 'projects'
.term
= render 'shared/projects/list', projects: @search_objects, pipeline_status: false
- elsif %w[blobs wiki_blobs].include?(@scope)
= render partial: 'search/results/blob', collection: @search_objects, locals: { projects: blob_projects(@search_objects) }
- else
= render partial: "search/results/#{@scope.singularize}", collection: @search_objects
- locals = { projects: blob_projects(@search_objects) } if %w[blobs wiki_blobs].include?(@scope)
= render partial: "search/results/#{@scope.singularize}", collection: @search_objects, locals: locals

- if @scope != 'projects'
= paginate_collection(@search_objects)
5 changes: 5 additions & 0 deletions changelogs/unreleased/60906-fix-wiki-links.yml
@@ -0,0 +1,5 @@
---
title: Show proper wiki links in search results
merge_request: 27634
author:
type: fixed
24 changes: 24 additions & 0 deletions spec/controllers/search_controller_spec.rb
Expand Up @@ -11,6 +11,30 @@
sign_in(user)
end

context 'uses the right partials depending on scope' do
using RSpec::Parameterized::TableSyntax
render_views

set(:project) { create(:project, :public, :repository, :wiki_repo) }

subject { get(:show, params: { project_id: project.id, scope: scope, search: 'merge' }) }

where(:partial, :scope) do
'_blob' | :blobs
'_wiki_blob' | :wiki_blobs
'_commit' | :commits
end

with_them do
it do
project_wiki = create(:project_wiki, project: project, user: user)
create(:wiki_page, wiki: project_wiki, attrs: { title: 'merge', content: 'merge' })

expect(subject).to render_template("search/results/#{partial}")
end
end
end

it 'finds issue comments' do
project = create(:project, :public)
note = create(:note_on_issue, project: project)
Expand Down

0 comments on commit f04f690

Please sign in to comment.