Fix broken commits search
This commit is contained in:
parent
6be0c160d3
commit
ebc44befdc
7 changed files with 66 additions and 2 deletions
|
@ -16,7 +16,7 @@ class SearchController < ApplicationController
|
|||
@group = nil unless can?(current_user, :read_group, @group)
|
||||
end
|
||||
|
||||
return if params[:search].nil? || params[:search].blank?
|
||||
return if params[:search].blank?
|
||||
|
||||
@search_term = params[:search]
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
= render 'projects/commits/commit', project: @project, commit: commit
|
||||
= render 'projects/commits/commit', project: @project, commit: commit, ref: nil
|
||||
|
|
4
changelogs/unreleased/24255-search-fix.yml
Normal file
4
changelogs/unreleased/24255-search-fix.yml
Normal file
|
@ -0,0 +1,4 @@
|
|||
---
|
||||
title: Fix broken commits search
|
||||
merge_request:
|
||||
author:
|
28
spec/features/global_search_spec.rb
Normal file
28
spec/features/global_search_spec.rb
Normal file
|
@ -0,0 +1,28 @@
|
|||
require 'spec_helper'
|
||||
|
||||
feature 'Global search', feature: true do
|
||||
let(:user) { create(:user) }
|
||||
let(:project) { create(:project, namespace: user.namespace) }
|
||||
|
||||
before do
|
||||
project.team << [user, :master]
|
||||
login_with(user)
|
||||
end
|
||||
|
||||
describe 'I search through the issues and I see pagination' do
|
||||
before do
|
||||
allow_any_instance_of(Gitlab::SearchResults).to receive(:per_page).and_return(1)
|
||||
create_list(:issue, 2, project: project, title: 'initial')
|
||||
end
|
||||
|
||||
it "has a pagination" do
|
||||
visit dashboard_projects_path
|
||||
|
||||
fill_in "search", with: "initial"
|
||||
click_button "Go"
|
||||
|
||||
select_filter("Issues")
|
||||
expect(page).to have_selector('.gl-pagination .page', count: 2)
|
||||
end
|
||||
end
|
||||
end
|
|
@ -100,6 +100,32 @@ describe "Search", feature: true do
|
|||
|
||||
expect(page).to have_link(snippet.title)
|
||||
end
|
||||
|
||||
it 'finds a commit' do
|
||||
visit namespace_project_path(project.namespace, project)
|
||||
|
||||
page.within '.search' do
|
||||
fill_in 'search', with: 'add'
|
||||
click_button 'Go'
|
||||
end
|
||||
|
||||
click_link "Commits"
|
||||
|
||||
expect(page).to have_selector('.commit-row-description')
|
||||
end
|
||||
|
||||
it 'finds a code' do
|
||||
visit namespace_project_path(project.namespace, project)
|
||||
|
||||
page.within '.search' do
|
||||
fill_in 'search', with: 'def'
|
||||
click_button 'Go'
|
||||
end
|
||||
|
||||
click_link "Code"
|
||||
|
||||
expect(page).to have_selector('.file-content .code')
|
||||
end
|
||||
end
|
||||
|
||||
describe 'Right header search field', feature: true do
|
||||
|
|
|
@ -29,6 +29,7 @@ RSpec.configure do |config|
|
|||
config.include Devise::Test::ControllerHelpers, type: :controller
|
||||
config.include Warden::Test::Helpers, type: :request
|
||||
config.include LoginHelpers, type: :feature
|
||||
config.include SearchHelpers, type: :feature
|
||||
config.include StubConfiguration
|
||||
config.include EmailHelpers
|
||||
config.include TestEnv
|
||||
|
|
5
spec/support/search_helpers.rb
Normal file
5
spec/support/search_helpers.rb
Normal file
|
@ -0,0 +1,5 @@
|
|||
module SearchHelpers
|
||||
def select_filter(name)
|
||||
find(:xpath, "//ul[contains(@class, 'search-filter')]//a[contains(.,'#{name}')]").click
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue