[Git][noosfero/noosfero][master] 2 commits: Put limit on tag search

Bráulio Bhavamitra gitlab at gitlab.com
Fri Jun 26 10:09:33 BRT 2015


Bráulio Bhavamitra pushed to branch master at Noosfero / noosfero


Commits:
3e3dcb24 by Braulio Bhavamitra at 2015-06-25T23:12:12Z
Put limit on tag search

- - - - -
9e90cb78 by Bráulio Bhavamitra at 2015-06-26T13:09:34Z
Merge branch 'limit-tag-search' into 'master'

Put limit on tag search

See merge request !553

- - - - -


2 changed files:

- app/controllers/my_profile/cms_controller.rb
- test/functional/cms_controller_test.rb


Changes:

=====================================
app/controllers/my_profile/cms_controller.rb
=====================================
--- a/app/controllers/my_profile/cms_controller.rb
+++ b/app/controllers/my_profile/cms_controller.rb
@@ -6,7 +6,7 @@ class CmsController < MyProfileController
 
   def search_tags
     arg = params[:term].downcase
-    result = ActsAsTaggableOn::Tag.find(:all, :conditions => ['LOWER(name) LIKE ?', "%#{arg}%"])
+    result = ActsAsTaggableOn::Tag.where('name ILIKE ?', "%#{arg}%").limit(10)
     render :text => prepare_to_token_input_by_label(result).to_json, :content_type => 'application/json'
   end
 


=====================================
test/functional/cms_controller_test.rb
=====================================
--- a/test/functional/cms_controller_test.rb
+++ b/test/functional/cms_controller_test.rb
@@ -1891,8 +1891,8 @@ class CmsControllerTest < ActionController::TestCase
   end
 
   should 'return tags found' do
-    tag = mock; tag.stubs(:name).returns('linux')
-    ActsAsTaggableOn::Tag.stubs(:find).returns([tag])
+    a = profile.articles.create(:name => 'blablabla')
+    a.tags.create! name: 'linux'
     get :search_tags, :profile => profile.identifier, :term => 'linux'
     assert_equal '[{"label":"linux","value":"linux"}]', @response.body
   end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/abbed37f60de7abf1944fa5125cc080b2a07e1f2...9e90cb78a8f37df5984b2862f2e1646c58702522
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20150626/cd557169/attachment-0001.html>


More information about the Noosfero-dev mailing list