From 2409576dbd82c6c60eaf8350b3ded1f739169e5a Mon Sep 17 00:00:00 2001 From: Leandro Nunes dos Santos Date: Wed, 28 Oct 2015 15:59:41 -0300 Subject: [PATCH] adding article entities attributes --- lib/noosfero/api/entities.rb | 4 +++- test/unit/api/articles_test.rb | 13 +++++++++++++ 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/noosfero/api/entities.rb b/lib/noosfero/api/entities.rb index d04194e..8acb406 100644 --- a/lib/noosfero/api/entities.rb +++ b/lib/noosfero/api/entities.rb @@ -115,9 +115,11 @@ module Noosfero expose :end_date, :documentation => {type: 'DateTime', desc: 'The date of finish of the article'} expose :tag_list expose :children_count - expose :followers_count expose :slug, :documentation => {:type => "String", :desc => "Trimmed and parsed name of a article"} expose :path + expose :followers_count + expose :votes_count + expose :comments_count end class Article < ArticleBase diff --git a/test/unit/api/articles_test.rb b/test/unit/api/articles_test.rb index a0a568f..3235f38 100644 --- a/test/unit/api/articles_test.rb +++ b/test/unit/api/articles_test.rb @@ -607,4 +607,17 @@ class ArticlesTest < ActiveSupport::TestCase assert_equal json['articles'].count, 2 end + ARTICLE_ATTRIBUTES = %w(followers_count votes_count comments_count) + + ARTICLE_ATTRIBUTES.map do |attribute| + + define_method "test_should_expose_#{attribute}_attribute_in_article_enpoints" do + article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") + get "/api/v1/articles/#{article.id}?#{params.to_query}" + json = JSON.parse(last_response.body) + assert_not_nil json['article'][attribute] + end + + end + end -- libgit2 0.21.2