2012-05-27 06:22:23 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2014-04-12 04:56:37 -04:00
|
|
|
describe "Search", feature: true do
|
2016-03-31 03:21:20 -04:00
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
2016-06-24 12:45:55 -04:00
|
|
|
let!(:issue) { create(:issue, project: project, assignee: user) }
|
|
|
|
let!(:issue2) { create(:issue, project: project, author: user) }
|
2016-03-31 03:21:20 -04:00
|
|
|
|
2012-05-27 06:22:23 -04:00
|
|
|
before do
|
2016-03-31 03:21:20 -04:00
|
|
|
login_with(user)
|
|
|
|
project.team << [user, :reporter]
|
2012-05-27 06:22:23 -04:00
|
|
|
visit search_path
|
2016-03-31 03:21:20 -04:00
|
|
|
end
|
2016-04-13 17:43:07 -04:00
|
|
|
|
|
|
|
it 'top right search form is not present' do
|
|
|
|
expect(page).not_to have_selector('.search')
|
|
|
|
end
|
2013-02-21 06:28:05 -05:00
|
|
|
|
2016-03-31 03:21:20 -04:00
|
|
|
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
|
2013-02-21 06:28:05 -05:00
|
|
|
end
|
2012-05-27 06:22:23 -04:00
|
|
|
end
|
|
|
|
|
2016-03-31 03:21:20 -04:00
|
|
|
context 'search for comments' do
|
2016-07-29 15:20:00 -04:00
|
|
|
context 'when comment belongs to a invalid commit' do
|
|
|
|
let(:note) { create(:note_on_commit, author: user, project: project, commit_id: project.repository.commit.id, note: 'Bug here') }
|
|
|
|
|
|
|
|
before { note.update_attributes(commit_id: 12345678) }
|
|
|
|
|
|
|
|
it 'finds comment' do
|
|
|
|
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_text("Commit deleted")
|
|
|
|
expect(page).to have_text("12345678")
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2016-03-31 03:21:20 -04:00
|
|
|
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
|
2012-05-27 06:22:23 -04:00
|
|
|
end
|
2016-06-07 10:54:29 -04:00
|
|
|
|
|
|
|
describe 'Right header search field', feature: true do
|
|
|
|
describe 'Search in project page' do
|
|
|
|
before do
|
|
|
|
visit namespace_project_path(project.namespace, project)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'top right search form is present' do
|
|
|
|
expect(page).to have_selector('#search')
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'top right search form contains location badge' do
|
|
|
|
expect(page).to have_selector('.has-location-badge')
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'clicking the search field', js: true do
|
|
|
|
it 'should show category search dropdown' do
|
|
|
|
page.find('#search').click
|
|
|
|
|
2016-06-09 18:05:09 -04:00
|
|
|
expect(page).to have_selector('.dropdown-header', text: /#{project.name}/i)
|
2016-06-07 10:54:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'click the links in the category search dropdown', js: true do
|
|
|
|
before do
|
|
|
|
page.find('#search').click
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should take user to her issues page when issues assigned is clicked' do
|
|
|
|
find('.dropdown-menu').click_link 'Issues assigned to me'
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
expect(page).to have_selector('.issues-holder')
|
|
|
|
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should take user to her issues page when issues authored is clicked' do
|
|
|
|
find('.dropdown-menu').click_link "Issues I've created"
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
expect(page).to have_selector('.issues-holder')
|
|
|
|
expect(find('.js-author-search .dropdown-toggle-text')).to have_content(user.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should take user to her MR page when MR assigned is clicked' do
|
|
|
|
find('.dropdown-menu').click_link 'Merge requests assigned to me'
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
expect(page).to have_selector('.merge-requests-holder')
|
|
|
|
expect(find('.js-assignee-search .dropdown-toggle-text')).to have_content(user.name)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should take user to her MR page when MR authored is clicked' do
|
|
|
|
find('.dropdown-menu').click_link "Merge requests I've created"
|
|
|
|
sleep 2
|
|
|
|
|
|
|
|
expect(page).to have_selector('.merge-requests-holder')
|
|
|
|
expect(find('.js-author-search .dropdown-toggle-text')).to have_content(user.name)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'entering text into the search field', js: true do
|
|
|
|
before do
|
|
|
|
page.within '.search-input-wrap' do
|
|
|
|
fill_in "search", with: project.name[0..3]
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should not display the category search dropdown' do
|
2016-06-09 18:05:09 -04:00
|
|
|
expect(page).not_to have_selector('.dropdown-header', text: /#{project.name}/i)
|
2016-06-07 10:54:29 -04:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2012-05-27 06:22:23 -04:00
|
|
|
end
|