[Git][noosfero/noosfero][master] 2 commits: api: list only published children when get an article

Marcos Ronaldo Pereira Junior gitlab at mg.gitlab.com
Wed May 4 19:48:49 BRT 2016


Marcos Ronaldo Pereira Junior pushed to branch master at Noosfero / noosfero


Commits:
0b6f316d by Victor Costa at 2016-05-04T15:54:50-03:00
api: list only published children when get an article

- - - - -
a2a9a8bb by Marcos Ronaldo Pereira Junior at 2016-05-04T22:48:40+00:00
Merge branch 'articles-children-api' into 'master'

api: list only published children when get an article



See merge request !895
- - - - -


2 changed files:

- lib/noosfero/api/entities.rb
- test/api/articles_test.rb


Changes:

=====================================
lib/noosfero/api/entities.rb
=====================================
--- a/lib/noosfero/api/entities.rb
+++ b/lib/noosfero/api/entities.rb
@@ -203,7 +203,7 @@ module Noosfero
         root 'articles', 'article'
         expose :parent, :using => ArticleBase
         expose :children, :using => ArticleBase do |article, options|
-          article.children.limit(Noosfero::API::V1::Articles::MAX_PER_PAGE)
+          article.children.published.limit(Noosfero::API::V1::Articles::MAX_PER_PAGE)
         end
       end
 


=====================================
test/api/articles_test.rb
=====================================
--- a/test/api/articles_test.rb
+++ b/test/api/articles_test.rb
@@ -735,4 +735,13 @@ class ArticlesTest < ActiveSupport::TestCase
     assert_not_includes json["article"].keys, "comments"
   end
 
+  should 'not list private child when get the parent article' do
+    person = fast_create(Person, :environment_id => environment.id)
+    article = fast_create(Article, :profile_id => person.id, :name => "Some thing")
+    child = fast_create(Article, :parent_id => article.id, :profile_id => person.id, :name => "Some thing", :published => false)
+    get "/api/v1/articles/#{article.id}?#{params.to_query}"
+    json = JSON.parse(last_response.body)
+    assert_not_includes json['article']['children'].map {|a| a['id']}, child.id
+  end
+
 end



View it on GitLab: https://gitlab.com/noosfero/noosfero/compare/2a82a6868338e1621e119531ece116e1211ef1e1...a2a9a8bb828a489dede9ffd26279ff0a19174018
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listas.softwarelivre.org/pipermail/noosfero-dev/attachments/20160504/5c3ba199/attachment-0001.html>


More information about the Noosfero-dev mailing list