2019-12-21 20:55:43 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-23 00:09:42 +05:30
|
|
|
RSpec.describe SearchController, '(JavaScript fixtures)', type: :controller do
|
2018-03-17 18:26:18 +05:30
|
|
|
include JavaScriptFixturesHelpers
|
|
|
|
|
|
|
|
render_views
|
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
let_it_be(:user) { create(:user) }
|
2020-11-24 15:15:51 +05:30
|
|
|
|
|
|
|
before do
|
|
|
|
sign_in(user)
|
|
|
|
end
|
|
|
|
|
2019-09-04 21:01:54 +05:30
|
|
|
it 'search/show.html' do
|
2018-03-17 18:26:18 +05:30
|
|
|
get :show
|
|
|
|
|
2019-10-12 21:52:04 +05:30
|
|
|
expect(response).to be_successful
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
|
|
|
context 'search within a project' do
|
|
|
|
let(:namespace) { create(:namespace, name: 'frontend-fixtures') }
|
|
|
|
let(:project) { create(:project, :public, :repository, namespace: namespace, path: 'search-project') }
|
2021-01-29 00:20:46 +05:30
|
|
|
let(:blobs) do
|
2022-10-11 01:57:18 +05:30
|
|
|
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)
|
|
|
|
],
|
2021-01-29 00:20:46 +05:30
|
|
|
total_count: 4,
|
|
|
|
limit: 4,
|
|
|
|
offset: 0)
|
|
|
|
end
|
2020-04-22 19:07:51 +05:30
|
|
|
|
2021-02-22 17:27:13 +05:30
|
|
|
before do
|
|
|
|
project.add_developer(user)
|
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
it 'search/blob_search_result.html' do
|
2021-02-22 17:27:13 +05:30
|
|
|
allow_next_instance_of(SearchServicePresenter) do |search_service|
|
|
|
|
allow(search_service).to receive(:search_objects).and_return(blobs)
|
2021-01-29 00:20:46 +05:30
|
|
|
end
|
|
|
|
|
2020-04-22 19:07:51 +05:30
|
|
|
get :show, params: {
|
|
|
|
search: 'Send',
|
|
|
|
project_id: project.id,
|
|
|
|
scope: :blobs
|
|
|
|
}
|
|
|
|
|
|
|
|
expect(response).to be_successful
|
|
|
|
end
|
|
|
|
end
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|