diff --git a/app/models/recent_documents_block.rb b/app/models/recent_documents_block.rb index 3f38542..fd05945 100644 --- a/app/models/recent_documents_block.rb +++ b/app/models/recent_documents_block.rb @@ -29,4 +29,12 @@ class RecentDocumentsBlock < Block def self.expire_on { :profile => [:article], :environment => [:article] } end + + def api_content + Noosfero::API::Entities::ArticleBase.represent(docs).as_json + end + + def display_api_content_by_default? + false + end end diff --git a/test/unit/recent_documents_block_test.rb b/test/unit/recent_documents_block_test.rb index 9667bf1..19e3b99 100644 --- a/test/unit/recent_documents_block_test.rb +++ b/test/unit/recent_documents_block_test.rb @@ -128,4 +128,12 @@ class RecentDocumentsBlockViewTest < ActionView::TestCase box.expects(:owner).returns(Environment.new).at_least_once assert_equal '', render_block_footer(block) end + + should 'return articles in api_content' do + profile = fast_create(Profile) + article = fast_create(TextArticle, profile_id: profile.id) + block = RecentDocumentsBlock.new + block.stubs(:owner).returns(profile) + assert_equal [article.id], block.api_content['articles'].map {|a| a[:id]} + end end -- libgit2 0.21.2