Commit dbbfc9b6412b4b3198199942874615b4fa90473e
1 parent
c2743b18
Exists in
staging
and in
2 other branches
api: fix articles followed by me
Showing
2 changed files
with
10 additions
and
1 deletions
Show diff stats
lib/noosfero/api/v1/articles.rb
@@ -40,7 +40,7 @@ module Noosfero | @@ -40,7 +40,7 @@ module Noosfero | ||
40 | 40 | ||
41 | desc "Return the articles followed by me" | 41 | desc "Return the articles followed by me" |
42 | get 'followed_by_me' do | 42 | get 'followed_by_me' do |
43 | - present_articles(current_person, 'following_articles') | 43 | + present_articles_for_asset(current_person, 'following_articles') |
44 | end | 44 | end |
45 | 45 | ||
46 | desc "Return one article by id" do | 46 | desc "Return one article by id" do |
test/unit/api/articles_test.rb
@@ -667,6 +667,15 @@ class ArticlesTest < ActiveSupport::TestCase | @@ -667,6 +667,15 @@ class ArticlesTest < ActiveSupport::TestCase | ||
667 | assert_includes json["articles"].map { |a| a["id"] }, article2.id | 667 | assert_includes json["articles"].map { |a| a["id"] }, article2.id |
668 | end | 668 | end |
669 | 669 | ||
670 | + should 'list articles followed by me' do | ||
671 | + article1 = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") | ||
672 | + article2 = fast_create(Article, :profile_id => user.person.id, :name => "Some other thing") | ||
673 | + article1.person_followers << @person | ||
674 | + get "/api/v1/articles/followed_by_me?#{params.to_query}" | ||
675 | + json = JSON.parse(last_response.body) | ||
676 | + assert_equal [article1.id], json['articles'].map { |a| a['id'] } | ||
677 | + end | ||
678 | + | ||
670 | ARTICLE_ATTRIBUTES = %w(followers_count votes_count comments_count) | 679 | ARTICLE_ATTRIBUTES = %w(followers_count votes_count comments_count) |
671 | 680 | ||
672 | ARTICLE_ATTRIBUTES.map do |attribute| | 681 | ARTICLE_ATTRIBUTES.map do |attribute| |