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