From dbbfc9b6412b4b3198199942874615b4fa90473e Mon Sep 17 00:00:00 2001 From: Victor Costa Date: Mon, 15 Feb 2016 09:45:40 -0300 Subject: [PATCH] api: fix articles followed by me --- lib/noosfero/api/v1/articles.rb | 2 +- test/unit/api/articles_test.rb | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/noosfero/api/v1/articles.rb b/lib/noosfero/api/v1/articles.rb index 0ad9562..15395f0 100644 --- a/lib/noosfero/api/v1/articles.rb +++ b/lib/noosfero/api/v1/articles.rb @@ -40,7 +40,7 @@ module Noosfero desc "Return the articles followed by me" get 'followed_by_me' do - present_articles(current_person, 'following_articles') + present_articles_for_asset(current_person, 'following_articles') end desc "Return one article by id" do diff --git a/test/unit/api/articles_test.rb b/test/unit/api/articles_test.rb index c03237f..25b25ee 100644 --- a/test/unit/api/articles_test.rb +++ b/test/unit/api/articles_test.rb @@ -667,6 +667,15 @@ class ArticlesTest < ActiveSupport::TestCase assert_includes json["articles"].map { |a| a["id"] }, article2.id end + should 'list articles followed by me' do + article1 = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") + article2 = fast_create(Article, :profile_id => user.person.id, :name => "Some other thing") + article1.person_followers << @person + get "/api/v1/articles/followed_by_me?#{params.to_query}" + json = JSON.parse(last_response.body) + assert_equal [article1.id], json['articles'].map { |a| a['id'] } + end + ARTICLE_ATTRIBUTES = %w(followers_count votes_count comments_count) ARTICLE_ATTRIBUTES.map do |attribute| -- libgit2 0.21.2