Commit 6017a75c45c8cea4d125387f4a704b7a7aa6e18b
1 parent
41a24f5c
Exists in
theme-brasil-digital-from-staging
and in
9 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
test/unit/api/articles_test.rb
| ... | ... | @@ -100,6 +100,18 @@ class ArticlesTest < 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 | ... | ... |