Merge pull request #5317 from gdpelican/feature/strip-search-query

Feature/strip search query
This commit is contained in:
Jonne Haß 2014-10-14 13:18:32 +02:00
commit 8a63f6f1f7
3 changed files with 13 additions and 1 deletions

View file

@ -78,6 +78,7 @@ The keys will still be available in the root level within the 0.5 release. The o
* Increase possible captcha length [#5169](https://github.com/diaspora/diaspora/pull/5169)
* Display visibility icon in publisher aspects dropdown [#4982](https://github.com/diaspora/diaspora/pull/4982)
* Add a link to the reported comment in the admin panel [#5337](https://github.com/diaspora/diaspora/pull/5337)
* Strip search query from leading and trailing whitespace [#5317](https://github.com/diaspora/diaspora/pull/5317)
# 0.4.1.1

View file

@ -20,7 +20,7 @@ class SearchController < ApplicationController
private
def search_query
@search_query ||= params[:q] || params[:term] || ''
@search_query ||= (params[:q] || params[:term] || '').strip
end
end

View file

@ -35,5 +35,16 @@ describe SearchController, :type => :controller do
end
end
describe '#search_query' do
it 'strips the term parameter' do
@controller.params[:term] = ' IN SPACE! '
expect(@controller.send(:search_query)).to eq 'IN SPACE!'
end
it 'strips the q parameter' do
@controller.params[:q] = ' IN SPACE! '
expect(@controller.send(:search_query)).to eq 'IN SPACE!'
end
end
end