Commit dbbfc9b6412b4b3198199942874615b4fa90473e

Authored by Victor Costa
1 parent c2743b18

api: fix articles followed by me

lib/noosfero/api/v1/articles.rb
... ... @@ -40,7 +40,7 @@ module Noosfero
40 40  
41 41 desc "Return the articles followed by me"
42 42 get 'followed_by_me' do
43   - present_articles(current_person, 'following_articles')
  43 + present_articles_for_asset(current_person, 'following_articles')
44 44 end
45 45  
46 46 desc "Return one article by id" do
... ...
test/unit/api/articles_test.rb
... ... @@ -667,6 +667,15 @@ class ArticlesTest < ActiveSupport::TestCase
667 667 assert_includes json["articles"].map { |a| a["id"] }, article2.id
668 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 679 ARTICLE_ATTRIBUTES = %w(followers_count votes_count comments_count)
671 680  
672 681 ARTICLE_ATTRIBUTES.map do |attribute|
... ...