Commit cb4b0f3475f4cb60f03d920fc115c55508ca1218

Authored by Victor Costa
2 parents e750846e d8a07bd4

Merge branch 'api' into production

lib/noosfero/api/v1/articles.rb
... ... @@ -96,7 +96,7 @@ module Noosfero
96 96 #TODO make tests for this situation
97 97 votes_order = params.delete(:order) if params[:order]=='votes_score'
98 98 articles = select_filtered_collection_of(article, 'children', params)
99   - articles = articles.display_filter(current_person, nil)
  99 + articles = articles.display_filter(current_person, article.profile)
100 100  
101 101  
102 102 #TODO make tests for this situation
... ...
test/unit/api/articles_test.rb
... ... @@ -48,6 +48,15 @@ class ArticlesTest < ActiveSupport::TestCase
48 48 assert_equivalent [child1.id, child2.id], json["articles"].map { |a| a["id"] }
49 49 end
50 50  
  51 + should 'list public article children for not logged in access' do
  52 + article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing")
  53 + child1 = fast_create(Article, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing")
  54 + child2 = fast_create(Article, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing")
  55 + get "/api/v1/articles/#{article.id}/children"
  56 + json = JSON.parse(last_response.body)
  57 + assert_equivalent [child1.id, child2.id], json["articles"].map { |a| a["id"] }
  58 + end
  59 +
51 60 should 'not list children of forbidden article' do
52 61 person = fast_create(Person, :environment_id => environment.id)
53 62 article = fast_create(Article, :profile_id => person.id, :name => "Some thing", :published => false)
... ...