2014-09-02 18:07:02 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Search", feature: true do
|
2016-06-02 11:05:42 +05:30
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
|
|
|
|
2014-09-02 18:07:02 +05:30
|
|
|
before do
|
2016-06-02 11:05:42 +05:30
|
|
|
login_with(user)
|
|
|
|
project.team << [user, :reporter]
|
2014-09-02 18:07:02 +05:30
|
|
|
visit search_path
|
2016-06-02 11:05:42 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
it 'top right search form is not present' do
|
|
|
|
expect(page).not_to have_selector('.search')
|
|
|
|
end
|
|
|
|
|
|
|
|
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
|
2014-09-02 18:07:02 +05:30
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
expect(page).to have_content project.name
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-06-02 11:05:42 +05:30
|
|
|
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
|
2014-09-02 18:07:02 +05:30
|
|
|
end
|
|
|
|
end
|