Merge pull request #5317 from gdpelican/feature/strip-search-query
Feature/strip search query
This commit is contained in:
commit
8a63f6f1f7
3 changed files with 13 additions and 1 deletions
|
|
@ -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)
|
* 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)
|
* 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)
|
* 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
|
# 0.4.1.1
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,7 @@ class SearchController < ApplicationController
|
||||||
private
|
private
|
||||||
|
|
||||||
def search_query
|
def search_query
|
||||||
@search_query ||= params[:q] || params[:term] || ''
|
@search_query ||= (params[:q] || params[:term] || '').strip
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -35,5 +35,16 @@ describe SearchController, :type => :controller do
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue