2017-09-16 09:02:30 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe 'User searches for code' do
|
|
|
|
let(:user) { create(:user) }
|
|
|
|
let(:project) { create(:project, :repository, namespace: user.namespace) }
|
|
|
|
|
|
|
|
context 'when signed in' do
|
|
|
|
before do
|
|
|
|
project.add_master(user)
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'finds a file' do
|
|
|
|
visit(project_path(project))
|
|
|
|
|
|
|
|
page.within('.search') do
|
|
|
|
fill_in('search', with: 'application.js')
|
|
|
|
click_button('Go')
|
|
|
|
end
|
|
|
|
|
|
|
|
click_link('Code')
|
|
|
|
|
|
|
|
expect(page).to have_selector('.file-content .code')
|
|
|
|
expect(page).to have_selector("span.line[lang='javascript']")
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when on a project page', :js do
|
|
|
|
before do
|
|
|
|
visit(search_path)
|
|
|
|
end
|
|
|
|
|
|
|
|
include_examples 'top right search form'
|
|
|
|
|
|
|
|
it 'finds code' do
|
2017-09-25 16:14:19 +00:00
|
|
|
find('.js-search-project-dropdown').click
|
2017-09-16 09:02:30 +00:00
|
|
|
|
|
|
|
page.within('.project-filter') do
|
2018-03-05 14:15:26 +00:00
|
|
|
click_link(project.full_name)
|
2017-09-16 09:02:30 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
fill_in('dashboard_search', with: 'rspec')
|
2017-09-25 16:14:19 +00:00
|
|
|
find('.btn-search').click
|
2017-09-16 09:02:30 +00:00
|
|
|
|
|
|
|
page.within('.results') do
|
|
|
|
expect(find(:css, '.search-results')).to have_content('Update capybara, rspec-rails, poltergeist to recent versions')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context 'when signed out' do
|
|
|
|
let(:project) { create(:project, :public, :repository) }
|
|
|
|
|
|
|
|
before do
|
|
|
|
visit(project_path(project))
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'finds code' do
|
|
|
|
fill_in('search', with: 'rspec')
|
|
|
|
click_button('Go')
|
|
|
|
|
|
|
|
page.within('.results') do
|
|
|
|
expect(find(:css, '.search-results')).to have_content('Update capybara, rspec-rails, poltergeist to recent versions')
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|