Commit cb4b0f3475f4cb60f03d920fc115c55508ca1218
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
Merge branch 'api' into production
Showing
2 changed files
with
10 additions
and
1 deletions
Show diff stats
lib/noosfero/api/v1/articles.rb
@@ -96,7 +96,7 @@ module Noosfero | @@ -96,7 +96,7 @@ module Noosfero | ||
96 | #TODO make tests for this situation | 96 | #TODO make tests for this situation |
97 | votes_order = params.delete(:order) if params[:order]=='votes_score' | 97 | votes_order = params.delete(:order) if params[:order]=='votes_score' |
98 | articles = select_filtered_collection_of(article, 'children', params) | 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 | #TODO make tests for this situation | 102 | #TODO make tests for this situation |
test/unit/api/articles_test.rb
@@ -48,6 +48,15 @@ class ArticlesTest < ActiveSupport::TestCase | @@ -48,6 +48,15 @@ class ArticlesTest < ActiveSupport::TestCase | ||
48 | assert_equivalent [child1.id, child2.id], json["articles"].map { |a| a["id"] } | 48 | assert_equivalent [child1.id, child2.id], json["articles"].map { |a| a["id"] } |
49 | end | 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 | should 'not list children of forbidden article' do | 60 | should 'not list children of forbidden article' do |
52 | person = fast_create(Person, :environment_id => environment.id) | 61 | person = fast_create(Person, :environment_id => environment.id) |
53 | article = fast_create(Article, :profile_id => person.id, :name => "Some thing", :published => false) | 62 | article = fast_create(Article, :profile_id => person.id, :name => "Some thing", :published => false) |