Commit 6017a75c45c8cea4d125387f4a704b7a7aa6e18b
1 parent
41a24f5c
Exists in
staging
and in
4 other branches
api: expose article followers count
Showing
2 changed files
with
13 additions
and
0 deletions
Show diff stats
lib/noosfero/api/entities.rb
@@ -97,6 +97,7 @@ module Noosfero | @@ -97,6 +97,7 @@ module Noosfero | ||
97 | expose :end_date, :documentation => {type: 'DateTime', desc: 'The date of finish of the article'} | 97 | expose :end_date, :documentation => {type: 'DateTime', desc: 'The date of finish of the article'} |
98 | expose :tag_list | 98 | expose :tag_list |
99 | expose :children_count | 99 | expose :children_count |
100 | + expose :followers_count | ||
100 | end | 101 | end |
101 | 102 | ||
102 | class Article < ArticleBase | 103 | class Article < ArticleBase |
test/unit/api/articles_test.rb
@@ -100,6 +100,18 @@ class ArticlesTest < ActiveSupport::TestCase | @@ -100,6 +100,18 @@ class ArticlesTest < ActiveSupport::TestCase | ||
100 | assert_equal true, json['success'] | 100 | assert_equal true, json['success'] |
101 | end | 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 | should 'return the followers of a article identified by id' do | 115 | should 'return the followers of a article identified by id' do |
104 | article = fast_create(Article, :profile_id => @person.id, :name => "Some thing") | 116 | article = fast_create(Article, :profile_id => @person.id, :name => "Some thing") |
105 | 117 |