2019-10-12 21:52:04 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'User searches for merge requests', :js do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, namespace: user.namespace) }
|
|
|
|
let!(:merge_request1) { create(:merge_request, title: 'Foo', source_project: project, target_project: project) }
|
|
|
|
let!(:merge_request2) { create(:merge_request, :simple, title: 'Bar', source_project: project, target_project: project) }
|
|
|
|
|
|
|
|
before do
|
2018-11-18 11:00:15 +05:30
|
|
|
project.add_maintainer(user)
|
2018-03-17 18:26:18 +05:30
|
|
|
sign_in(user)
|
|
|
|
|
|
|
|
visit(search_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'top right search form'
|
|
|
|
|
|
|
|
it 'finds a merge request' do
|
|
|
|
fill_in('dashboard_search', with: merge_request1.title)
|
|
|
|
find('.btn-search').click
|
|
|
|
|
|
|
|
page.within('.search-filter') do
|
|
|
|
click_link('Merge requests')
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.results') do
|
|
|
|
expect(find(:css, '.search-results')).to have_link(merge_request1.title).and have_no_link(merge_request2.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when on a project page' do
|
|
|
|
it 'finds a merge request' do
|
|
|
|
find('.js-search-project-dropdown').click
|
|
|
|
|
|
|
|
page.within('.project-filter') do
|
2018-03-27 19:54:05 +05:30
|
|
|
click_link(project.full_name)
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
|
|
|
fill_in('dashboard_search', with: merge_request1.title)
|
|
|
|
find('.btn-search').click
|
|
|
|
|
|
|
|
page.within('.search-filter') do
|
|
|
|
click_link('Merge requests')
|
|
|
|
end
|
|
|
|
|
|
|
|
page.within('.results') do
|
|
|
|
expect(find(:css, '.search-results')).to have_link(merge_request1.title).and have_no_link(merge_request2.title)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|