BigW Consortium Gitlab

search_spec.rb 1.34 KB
Newer Older
1 2
require 'spec_helper'

3
describe "Search", feature: true  do
4 5 6
  let(:user) { create(:user) }
  let(:project) { create(:project, namespace: user.namespace) }

7
  before do
8 9
    login_with(user)
    project.team << [user, :reporter]
10
    visit search_path
11
  end
12 13 14 15

  it 'top right search form is not present' do
    expect(page).not_to have_selector('.search')
  end
16

17 18 19 20 21 22 23 24
  describe 'searching for Projects' do
    it 'finds a project' do
      page.within '.search-holder' do
        fill_in "search", with: project.name[0..3]
        click_button "Search"
      end

      expect(page).to have_content project.name
25
    end
26 27
  end

28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
  context 'search for comments' do
    it 'finds a snippet' do
      snippet = create(:project_snippet, :private, project: project, author: user, title: 'Some title')
      note = create(:note,
                    noteable: snippet,
                    author: user,
                    note: 'Supercalifragilisticexpialidocious',
                    project: project)
      # Must visit project dashboard since global search won't search
      # everything (e.g. comments, snippets, etc.)
      visit namespace_project_path(project.namespace, project)

      page.within '.search' do
        fill_in 'search', with: note.note
        click_button 'Go'
      end

      click_link 'Comments'

      expect(page).to have_link(snippet.title)
    end
49 50
  end
end