[Git][noosfero/noosfero][master] 2 commits: api: search by tag

Leandro Nunes gitlab at mg.gitlab.com
Tue Aug 1 11:51:50 BRT 2017


Leandro Nunes pushed to branch master at Noosfero / noosfero


Commits:
22d6d803 by Victor Costa at 2017-07-26T13:51:51-03:00
api: search by tag

- - - - -
b7b2deca by Leandro Nunes at 2017-08-01T14:51:30+00:00
Merge branch 'search-tag' into 'master'

api: search by tag

See merge request !1286
- - - - -


2 changed files:

- app/api/v1/search.rb
- test/api/search_test.rb


Changes:

=====================================
app/api/v1/search.rb
=====================================
--- a/app/api/v1/search.rb
+++ b/app/api/v1/search.rb
@@ -21,7 +21,7 @@ module Api
             query = params[:query] || ""
             order = "more_recent"
 
-            options = {:filter => order, :template_id => params[:template_id]}
+            options = {filter: order, template_id: params[:template_id], tag: params[:tag]}
 
             search_result = find_by_contents(asset, context, scope, query, {:page => 1}, options)
 


=====================================
test/api/search_test.rb
=====================================
--- a/test/api/search_test.rb
+++ b/test/api/search_test.rb
@@ -159,4 +159,14 @@ class SearchTest < ActiveSupport::TestCase
     get "/api/v1/search/article"
     assert_equal Api::Status::DEPRECATED, last_response.status
   end
+
+  should 'list articles by tag' do
+    fast_create(Article, :profile_id => person.id)
+    article = fast_create(TextArticle, :profile_id => person.id)
+    article.tag_list.add('test')
+    article.save!
+    get "/api/v1/search/article?tag=test"
+    json = JSON.parse(last_response.body)
+    assert_equal article.id, json.first['id']
+  end
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/c47fd6bc219d2d6ca078b43ee5d29b6c6fd8add1...b7b2deca38bbc02dbebd8156890038b19dfd3e0f

---
View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/c47fd6bc219d2d6ca078b43ee5d29b6c6fd8add1...b7b2deca38bbc02dbebd8156890038b19dfd3e0f
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20170801/bb391d3d/attachment-0001.html>


More information about the Noosfero-dev mailing list