Commit d8a07bd4bd314566ff9b7b79ca437f3f8ad38dc8
1 parent
0ee6f0f6
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Fix display filter for article children
Showing
3 changed files
with
11 additions
and
2 deletions
Show diff stats
lib/noosfero/api/helpers.rb
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) |
| 53 | 62 | article = fast_create(Article, :profile_id => person.id, :name => "Some thing", :published => false) | ... | ... |