summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Schatz <jschatz@gitlab.com>2016-09-23 03:18:23 +0000
committerRuben Davila <rdavila84@gmail.com>2016-09-23 15:43:06 -0500
commit5793529abab230e4462bc42be37e0be8a3a732fb (patch)
tree479b50420ce3ece69545988f5e267c3b6cf9842b
parentc534dcc52972437e310fe3f639e54e9ada6400cc (diff)
downloadgitlab-ce-5793529abab230e4462bc42be37e0be8a3a732fb.tar.gz
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
-rw-r--r--CHANGELOG1
-rw-r--r--app/controllers/search_controller.rb4
-rw-r--r--spec/features/search_spec.rb32
3 files changed, 35 insertions, 2 deletions
diff --git a/CHANGELOG b/CHANGELOG
index bd7c043e646..8eb96a9920c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -49,6 +49,7 @@ v 8.12.0
- 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)
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