diff options
author | James Lopez <james@gitlab.com> | 2019-04-29 11:31:29 +0000 |
---|---|---|
committer | James Lopez <james@gitlab.com> | 2019-04-29 11:31:29 +0000 |
commit | cfe04803b54d77e7e76cfed8b427dba875fb9a24 (patch) | |
tree | f99cb9317506812f4ccbd9a4ffa4a023c2505137 | |
parent | 33d5ec5b56b680f299ddd2b2f5bd666141eafefc (diff) | |
parent | 2f36efa0871b61df2aa5f8c7546ac95148ecf4de (diff) | |
download | gitlab-ce-cfe04803b54d77e7e76cfed8b427dba875fb9a24.tar.gz |
Merge branch 'wiki-search-results-fix' into 'master'
Fix links to wiki pages with subdirectories in search
Closes #56234
See merge request gitlab-org/gitlab-ce!27400
-rw-r--r-- | app/views/search/results/_wiki_blob.html.haml | 2 | ||||
-rw-r--r-- | changelogs/unreleased/wiki-search-results-fix.yml | 5 | ||||
-rw-r--r-- | spec/features/search/user_searches_for_wiki_pages_spec.rb | 36 |
3 files changed, 31 insertions, 12 deletions
diff --git a/app/views/search/results/_wiki_blob.html.haml b/app/views/search/results/_wiki_blob.html.haml index b351ecd4edf..5847751b268 100644 --- a/app/views/search/results/_wiki_blob.html.haml +++ b/app/views/search/results/_wiki_blob.html.haml @@ -1,5 +1,5 @@ - project = find_project_for_result_blob(projects, wiki_blob) - wiki_blob = parse_search_result(wiki_blob) -- wiki_blob_link = project_wiki_path(project, wiki_blob.basename) +- wiki_blob_link = project_wiki_path(project, Pathname.new(wiki_blob.filename).sub_ext('')) = render partial: 'search/results/blob_data', locals: { blob: wiki_blob, project: project, file_name: wiki_blob.filename, blob_link: wiki_blob_link } diff --git a/changelogs/unreleased/wiki-search-results-fix.yml b/changelogs/unreleased/wiki-search-results-fix.yml new file mode 100644 index 00000000000..693867eb385 --- /dev/null +++ b/changelogs/unreleased/wiki-search-results-fix.yml @@ -0,0 +1,5 @@ +--- +title: fix wiki search result links in titles +merge_request: 27400 +author: khm +type: fixed diff --git a/spec/features/search/user_searches_for_wiki_pages_spec.rb b/spec/features/search/user_searches_for_wiki_pages_spec.rb index 7225ca65492..6d4facd0649 100644 --- a/spec/features/search/user_searches_for_wiki_pages_spec.rb +++ b/spec/features/search/user_searches_for_wiki_pages_spec.rb @@ -14,22 +14,36 @@ describe 'User searches for wiki pages', :js do include_examples 'top right search form' - it 'finds a page' do - find('.js-search-project-dropdown').click + shared_examples 'search wiki blobs' do + it 'finds a page' do + find('.js-search-project-dropdown').click - page.within('.project-filter') do - click_link(project.full_name) - end + page.within('.project-filter') do + click_link(project.full_name) + end + + fill_in('dashboard_search', with: 'content') + find('.btn-search').click + + page.within('.search-filter') do + click_link('Wiki') + end - fill_in('dashboard_search', with: 'content') - find('.btn-search').click + page.within('.results') do + expect(find(:css, '.search-results')).to have_link(wiki_page.title, href: project_wiki_path(project, wiki_page.slug)) + end + end + end - page.within('.search-filter') do - click_link('Wiki') + context 'when searching by content' do + it_behaves_like 'search wiki blobs' do + let(:search_term) { 'content' } end + end - page.within('.results') do - expect(find(:css, '.search-results')).to have_link(wiki_page.title) + context 'when searching by title' do + it_behaves_like 'search wiki blobs' do + let(:search_term) { 'test_wiki' } end end end |