2019-10-17 02:07:30 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-01-17 18:32:42 -05:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe SearchController, '(JavaScript fixtures)', type: :controller do
|
2018-01-17 18:32:42 -05:00
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
|
|
|
render_views
|
|
|
|
|
2020-12-07 07:10:00 -05:00
|
|
|
let_it_be(:user) { create(:user) }
|
2020-09-11 08:08:50 -04:00
|
|
|
|
2018-01-17 18:32:42 -05:00
|
|
|
before(:all) do
|
|
|
|
clean_frontend_fixtures('search/')
|
|
|
|
end
|
|
|
|
|
2020-09-11 08:08:50 -04:00
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2019-04-21 06:58:07 -04:00
|
|
|
it 'search/show.html' do
|
2018-01-17 18:32:42 -05:00
|
|
|
get :show
|
|
|
|
|
2019-07-17 18:15:53 -04:00
|
|
|
expect(response).to be_successful
|
2018-01-17 18:32:42 -05:00
|
|
|
end
|
2020-03-23 05:09:42 -04:00
|
|
|
|
|
|
|
context 'search within a project' do
|
|
|
|
let(:namespace) { create(:namespace, name: 'frontend-fixtures') }
|
|
|
|
let(:project) { create(:project, :public, :repository, namespace: namespace, path: 'search-project') }
|
2020-10-28 14:08:52 -04:00
|
|
|
let(:blobs) do
|
|
|
|
Kaminari.paginate_array([
|
|
|
|
Gitlab::Search::FoundBlob.new(
|
|
|
|
path: 'CHANGELOG',
|
|
|
|
basename: 'CHANGELOG',
|
|
|
|
ref: 'master',
|
|
|
|
data: "hello\nworld\nfoo\nSend # this is the highligh\nbaz\nboo\nbat",
|
|
|
|
project: project,
|
|
|
|
project_id: project.id,
|
|
|
|
startline: 2),
|
|
|
|
Gitlab::Search::FoundBlob.new(
|
|
|
|
path: 'CONTRIBUTING',
|
|
|
|
basename: 'CONTRIBUTING',
|
|
|
|
ref: 'master',
|
|
|
|
data: "hello\nworld\nfoo\nSend # this is the highligh\nbaz\nboo\nbat",
|
|
|
|
project: project,
|
|
|
|
project_id: project.id,
|
|
|
|
startline: 2),
|
|
|
|
Gitlab::Search::FoundBlob.new(
|
|
|
|
path: 'README',
|
|
|
|
basename: 'README',
|
|
|
|
ref: 'master',
|
|
|
|
data: "foo\nSend # this is the highlight\nbaz\nboo\nbat",
|
|
|
|
project: project,
|
|
|
|
project_id: project.id,
|
|
|
|
startline: 2),
|
|
|
|
Gitlab::Search::FoundBlob.new(
|
|
|
|
path: 'test',
|
|
|
|
basename: 'test',
|
|
|
|
ref: 'master',
|
|
|
|
data: "foo\nSend # this is the highlight\nbaz\nboo\nbat",
|
|
|
|
project: project,
|
|
|
|
project_id: project.id,
|
|
|
|
startline: 2)
|
|
|
|
],
|
|
|
|
total_count: 4,
|
|
|
|
limit: 4,
|
|
|
|
offset: 0)
|
|
|
|
end
|
2020-03-23 05:09:42 -04:00
|
|
|
|
2020-12-07 07:10:00 -05:00
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
|
|
|
|
2020-03-23 05:09:42 -04:00
|
|
|
it 'search/blob_search_result.html' do
|
2020-12-01 10:09:28 -05:00
|
|
|
allow_next_instance_of(SearchServicePresenter) do |search_service|
|
|
|
|
allow(search_service).to receive(:search_objects).and_return(blobs)
|
2020-10-28 14:08:52 -04:00
|
|
|
end
|
|
|
|
|
2020-03-23 05:09:42 -04:00
|
|
|
get :show, params: {
|
|
|
|
search: 'Send',
|
|
|
|
project_id: project.id,
|
|
|
|
scope: :blobs
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response).to be_successful
|
|
|
|
end
|
|
|
|
end
|
2018-01-17 18:32:42 -05:00
|
|
|
end
|