PageRenderTime 8ms CodeModel.GetById 1ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/spec/features/search/user_searches_for_wiki_pages_spec.rb

https://gitlab.com/tnir/gitlab-ce
Ruby | 48 lines | 36 code | 11 blank | 1 comment | 0 complexity | 8983e918a40df925c60e480c9d7b3c3e MD5 | raw file
 1# frozen_string_literal: true
 2
 3require 'spec_helper'
 4
 5describe 'User searches for wiki pages', :js do
 6  let(:user) { create(:user) }
 7  let(:project) { create(:project, :repository, :wiki_repo, namespace: user.namespace) }
 8  let!(:wiki_page) { create(:wiki_page, wiki: project.wiki, title: 'directory/title', content: 'Some Wiki content') }
 9
10  before do
11    project.add_maintainer(user)
12    sign_in(user)
13
14    visit(search_path)
15  end
16
17  include_examples 'top right search form'
18
19  shared_examples 'search wiki blobs' do
20    it 'finds a page' do
21      find('.js-search-project-dropdown').click
22
23      page.within('.project-filter') do
24        click_link(project.full_name)
25      end
26
27      fill_in('dashboard_search', with: search_term)
28      find('.btn-search').click
29      select_search_scope('Wiki')
30
31      page.within('.results') do
32        expect(page).to have_link(wiki_page.title, href: project_wiki_path(project, wiki_page.slug))
33      end
34    end
35  end
36
37  context 'when searching by content' do
38    it_behaves_like 'search wiki blobs' do
39      let(:search_term) { 'content' }
40    end
41  end
42
43  context 'when searching by title' do
44    it_behaves_like 'search wiki blobs' do
45      let(:search_term) { 'title' }
46    end
47  end
48end