Commit 6017a75c45c8cea4d125387f4a704b7a7aa6e18b

Authored by Victor Costa
1 parent 41a24f5c

api: expose article followers count

lib/noosfero/api/entities.rb
... ... @@ -97,6 +97,7 @@ module Noosfero
97 97 expose :end_date, :documentation => {type: 'DateTime', desc: 'The date of finish of the article'}
98 98 expose :tag_list
99 99 expose :children_count
  100 + expose :followers_count
100 101 end
101 102  
102 103 class Article < ArticleBase
... ...
test/unit/api/articles_test.rb
... ... @@ -100,6 +100,18 @@ class ArticlesTest &lt; ActiveSupport::TestCase
100 100 assert_equal true, json['success']
101 101 end
102 102  
  103 + should 'return the followers count of an article' do
  104 + article = fast_create(Article, :profile_id => @person.id, :name => "Some thing")
  105 +
  106 + article.person_followers << @person
  107 +
  108 + get "/api/v1/articles/#{article.id}"
  109 + json = JSON.parse(last_response.body)
  110 +
  111 + assert_equal 200, last_response.status
  112 + assert_equal 1, json['article']['followers_count']
  113 + end
  114 +
103 115 should 'return the followers of a article identified by id' do
104 116 article = fast_create(Article, :profile_id => @person.id, :name => "Some thing")
105 117  
... ...