Commit 9eb2ca425c667fd572624bac9fd939142d2213c1

Authored by Leandro Santos
1 parent 548bab10

HOTFIX API: expose children count attribute

lib/noosfero/api/entities.rb
... ... @@ -95,6 +95,7 @@ module Noosfero
95 95 expose :start_date
96 96 expose :end_date
97 97 expose :tag_list
  98 + expose :children_count
98 99 end
99 100  
100 101 class Article < ArticleBase
... ...
test/unit/api/articles_test.rb
... ... @@ -91,6 +91,17 @@ class ArticlesTest &lt; ActiveSupport::TestCase
91 91 assert_not_includes json['articles'].map {|a| a['id']}, child.id
92 92 end
93 93  
  94 + expose_attributes = %w(id body abstract created_at title author profile categories image votes_for votes_against setting position hits start_date end_date tag_list parent children children_count)
  95 +
  96 + expose_attributes.each do |attr|
  97 + should "expose article #{attr} attribute" do
  98 + article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing")
  99 + get "/api/v1/articles/?#{params.to_query}"
  100 + json = JSON.parse(last_response.body)
  101 + assert json["articles"].last.has_key?(attr)
  102 + end
  103 + end
  104 +
94 105 #############################
95 106 # Profile Articles #
96 107 #############################
... ...