diff options
author | Phil Hughes <me@iamphill.com> | 2016-09-09 12:08:49 +0100 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2016-09-12 09:00:57 +0100 |
commit | 47b49624b1caff3db026c69ac219aa48507eedaa (patch) | |
tree | 9c217cb5370dbfdd2da0890fb22b775315fb589d | |
parent | 3a59efd562d22ec3148101d794d99889ccc9b82b (diff) | |
download | gitlab-ce-47b49624b1caff3db026c69ac219aa48507eedaa.tar.gz |
Fixed search dropdown labels not displayingsearch-filters-label-fix
This would only happen when the search term was empty because the method was returning before the controller could find the group or project for the toggle
Closes #21783
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/controllers/search_controller.rb | 4 | ||||
-rw-r--r-- | spec/features/search_spec.rb | 32 |
3 files changed, 35 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG index 89c880467cd..63bda64f5d5 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -19,6 +19,7 @@ v 8.12.0 (unreleased) - Escape search term before passing it to Regexp.new !6241 (winniehell) - Fix pinned sidebar behavior in smaller viewports !6169 - Change merge_error column from string to text type + - Fix issue with search filter labels not displaying - Reduce contributions calendar data payload (ClemMakesApps) - Add `web_url` field to issue, merge request, and snippet API objects (Ben Boeckel) - Enable pipeline events by default !6278 diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 61517d21f9f..d01e0dedf52 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -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] diff --git a/spec/features/search_spec.rb b/spec/features/search_spec.rb index dcd3a2f17b0..1806200c82c 100644 --- a/spec/features/search_spec.rb +++ b/spec/features/search_spec.rb @@ -1,6 +1,8 @@ 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 |