Commit 8184feed8cde829f5d1ac150455e9a322897305b
1 parent
6fe7f895
Exists in
ratings_minor_fixes
and in
4 other branches
recent_documents: return block content in api call
Showing
2 changed files
with
16 additions
and
0 deletions
Show diff stats
app/models/recent_documents_block.rb
... | ... | @@ -29,4 +29,12 @@ class RecentDocumentsBlock < Block |
29 | 29 | def self.expire_on |
30 | 30 | { :profile => [:article], :environment => [:article] } |
31 | 31 | end |
32 | + | |
33 | + def api_content | |
34 | + Noosfero::API::Entities::ArticleBase.represent(docs).as_json | |
35 | + end | |
36 | + | |
37 | + def display_api_content_by_default? | |
38 | + false | |
39 | + end | |
32 | 40 | end | ... | ... |
test/unit/recent_documents_block_test.rb
... | ... | @@ -128,4 +128,12 @@ class RecentDocumentsBlockViewTest < ActionView::TestCase |
128 | 128 | box.expects(:owner).returns(Environment.new).at_least_once |
129 | 129 | assert_equal '', render_block_footer(block) |
130 | 130 | end |
131 | + | |
132 | + should 'return articles in api_content' do | |
133 | + profile = fast_create(Profile) | |
134 | + article = fast_create(TextArticle, profile_id: profile.id) | |
135 | + block = RecentDocumentsBlock.new | |
136 | + block.stubs(:owner).returns(profile) | |
137 | + assert_equal [article.id], block.api_content['articles'].map {|a| a[:id]} | |
138 | + end | |
131 | 139 | end | ... | ... |