Commit 9e90cb78a8f37df5984b2862f2e1646c58702522
Exists in
staging
and in
42 other branches
Merge branch 'limit-tag-search' into 'master'
Put limit on tag search See merge request !553
Showing
2 changed files
with
3 additions
and
3 deletions
Show diff stats
app/controllers/my_profile/cms_controller.rb
| ... | ... | @@ -6,7 +6,7 @@ class CmsController < MyProfileController |
| 6 | 6 | |
| 7 | 7 | def search_tags |
| 8 | 8 | arg = params[:term].downcase |
| 9 | - result = ActsAsTaggableOn::Tag.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"]) | |
| 9 | + result = ActsAsTaggableOn::Tag.where('name ILIKE ?', "%#{arg}%").limit(10) | |
| 10 | 10 | render :text => prepare_to_token_input_by_label(result).to_json, :content_type => 'application/json' |
| 11 | 11 | end |
| 12 | 12 | ... | ... |
test/functional/cms_controller_test.rb
| ... | ... | @@ -1891,8 +1891,8 @@ class CmsControllerTest < ActionController::TestCase |
| 1891 | 1891 | end |
| 1892 | 1892 | |
| 1893 | 1893 | should 'return tags found' do |
| 1894 | - tag = mock; tag.stubs(:name).returns('linux') | |
| 1895 | - ActsAsTaggableOn::Tag.stubs(:find).returns([tag]) | |
| 1894 | + a = profile.articles.create(:name => 'blablabla') | |
| 1895 | + a.tags.create! name: 'linux' | |
| 1896 | 1896 | get :search_tags, :profile => profile.identifier, :term => 'linux' |
| 1897 | 1897 | assert_equal '[{"label":"linux","value":"linux"}]', @response.body |
| 1898 | 1898 | end | ... | ... |