Commit 2a423e03 authored by Jacob Schatz's avatar Jacob Schatz

Merge branch 'search-filters-label-fix' into 'master'

Fixed search dropdown labels not displaying

## What does this MR do?

Returns the search controller method after finding the project & group.

## Why was this MR needed?

The search controller was returning early when the search term was empty causing a bug where the dropdown toggles wouldn't show the correct text - instead defaulting to `Any`.

## Screenshots (if relevant)

![Screen_Shot_2016-09-09_at_12.09.57](/uploads/8c6bb36f4e163312314611d2877d5fa4/Screen_Shot_2016-09-09_at_12.09.57.png)

## What are the relevant issue numbers?

Closes #21783

See merge request !6277
parents 8078f879 47b49624
......@@ -46,6 +46,7 @@ v 8.12.0 (unreleased)
- Fix file permissions change when updating a file on the Gitlab UI !5979
- Added horizontal padding on build page sidebar on code coverage block. !6196 (Vitaly Baev)
- Change merge_error column from string to text type
- Fix issue with search filter labels not displaying
- Reduce contributions calendar data payload (ClemMakesApps)
- Show all pipelines for merge requests even from discarded commits !6414
- Replace contributions calendar timezone payload with dates (ClemMakesApps)
......
......@@ -6,8 +6,6 @@ class SearchController < ApplicationController
layout 'search'
def show
return if params[:search].nil? || params[:search].blank?
if params[:project_id].present?
@project = Project.find_by(id: params[:project_id])
@project = nil unless can?(current_user, :download_code, @project)
......@@ -18,6 +16,8 @@ class SearchController < ApplicationController
@group = nil unless can?(current_user, :read_group, @group)
end
return if params[:search].nil? || params[:search].blank?
@search_term = params[:search]
@scope = params[:scope]
......
require 'spec_helper'
describe "Search", feature: true do
include WaitForAjax
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
let!(:issue) { create(:issue, project: project, assignee: user) }
......@@ -16,6 +18,36 @@ describe "Search", feature: true do
expect(page).not_to have_selector('.search')
end
context 'search filters', js: true do
let(:group) { create(:group) }
before do
group.add_owner(user)
end
it 'shows group name after filtering' do
find('.js-search-group-dropdown').click
wait_for_ajax
page.within '.search-holder' do
click_link group.name
end
expect(find('.js-search-group-dropdown')).to have_content(group.name)
end
it 'shows project name after filtering' do
page.within('.project-filter') do
find('.js-search-project-dropdown').click
wait_for_ajax
click_link project.name_with_namespace
end
expect(find('.js-search-project-dropdown')).to have_content(project.name_with_namespace)
end
end
describe 'searching for Projects' do
it 'finds a project' do
page.within '.search-holder' do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment