From 6017a75c45c8cea4d125387f4a704b7a7aa6e18b Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Wed, 9 Sep 2015 09:39:12 -0300 Subject: [PATCH] api: expose article followers count --- lib/noosfero/api/entities.rb | 1 + test/unit/api/articles_test.rb | 12 ++++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/lib/noosfero/api/entities.rb b/lib/noosfero/api/entities.rb index ad7983d..b484c16 100644 --- a/lib/noosfero/api/entities.rb +++ b/lib/noosfero/api/entities.rb @@ -97,6 +97,7 @@ 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 end class Article < ArticleBase diff --git a/test/unit/api/articles_test.rb b/test/unit/api/articles_test.rb index 9088b2a..f18eb84 100644 --- a/test/unit/api/articles_test.rb +++ b/test/unit/api/articles_test.rb @@ -100,6 +100,18 @@ class ArticlesTest < ActiveSupport::TestCase assert_equal true, json['success'] end + should 'return the followers count of an article' do + article = fast_create(Article, :profile_id => @person.id, :name => "Some thing") + + article.person_followers << @person + + get "/api/v1/articles/#{article.id}" + json = JSON.parse(last_response.body) + + assert_equal 200, last_response.status + assert_equal 1, json['article']['followers_count'] + end + should 'return the followers of a article identified by id' do article = fast_create(Article, :profile_id => @person.id, :name => "Some thing") -- libgit2 0.21.2