Commit 9eb2ca425c667fd572624bac9fd939142d2213c1
1 parent
548bab10
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
HOTFIX API: expose children count attribute
Showing
2 changed files
with
12 additions
and
0 deletions
Show diff stats
lib/noosfero/api/entities.rb
@@ -95,6 +95,7 @@ module Noosfero | @@ -95,6 +95,7 @@ module Noosfero | ||
95 | expose :start_date | 95 | expose :start_date |
96 | expose :end_date | 96 | expose :end_date |
97 | expose :tag_list | 97 | expose :tag_list |
98 | + expose :children_count | ||
98 | end | 99 | end |
99 | 100 | ||
100 | class Article < ArticleBase | 101 | class Article < ArticleBase |
test/unit/api/articles_test.rb
@@ -91,6 +91,17 @@ class ArticlesTest < ActiveSupport::TestCase | @@ -91,6 +91,17 @@ class ArticlesTest < ActiveSupport::TestCase | ||
91 | assert_not_includes json['articles'].map {|a| a['id']}, child.id | 91 | assert_not_includes json['articles'].map {|a| a['id']}, child.id |
92 | end | 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 | # Profile Articles # | 106 | # Profile Articles # |
96 | ############################# | 107 | ############################# |