Commit 2409576dbd82c6c60eaf8350b3ded1f739169e5a
1 parent
a78018eb
Exists in
theme-brasil-digital-from-staging
and in
9 other branches
adding article entities attributes
Showing
2 changed files
with
16 additions
and
1 deletions
Show diff stats
lib/noosfero/api/entities.rb
... | ... | @@ -115,9 +115,11 @@ module Noosfero |
115 | 115 | expose :end_date, :documentation => {type: 'DateTime', desc: 'The date of finish of the article'} |
116 | 116 | expose :tag_list |
117 | 117 | expose :children_count |
118 | - expose :followers_count | |
119 | 118 | expose :slug, :documentation => {:type => "String", :desc => "Trimmed and parsed name of a article"} |
120 | 119 | expose :path |
120 | + expose :followers_count | |
121 | + expose :votes_count | |
122 | + expose :comments_count | |
121 | 123 | end |
122 | 124 | |
123 | 125 | class Article < ArticleBase | ... | ... |
test/unit/api/articles_test.rb
... | ... | @@ -607,4 +607,17 @@ class ArticlesTest < ActiveSupport::TestCase |
607 | 607 | assert_equal json['articles'].count, 2 |
608 | 608 | end |
609 | 609 | |
610 | + ARTICLE_ATTRIBUTES = %w(followers_count votes_count comments_count) | |
611 | + | |
612 | + ARTICLE_ATTRIBUTES.map do |attribute| | |
613 | + | |
614 | + define_method "test_should_expose_#{attribute}_attribute_in_article_enpoints" do | |
615 | + article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") | |
616 | + get "/api/v1/articles/#{article.id}?#{params.to_query}" | |
617 | + json = JSON.parse(last_response.body) | |
618 | + assert_not_nil json['article'][attribute] | |
619 | + end | |
620 | + | |
621 | + end | |
622 | + | |
610 | 623 | end | ... | ... |