Commit 8b3a53b888d8e3761b9ac9c1744f9195470b6362
1 parent
6d54bf95
Exists in
ratings_minor_fixes
and in
3 other branches
comment_paragraph: return discussions in api content
Showing
2 changed files
with
21 additions
and
0 deletions
Show diff stats
plugins/comment_paragraph/lib/comment_paragraph_plugin/discussion_block.rb
@@ -49,4 +49,11 @@ class CommentParagraphPlugin::DiscussionBlock < Block | @@ -49,4 +49,11 @@ class CommentParagraphPlugin::DiscussionBlock < Block | ||
49 | attr == self.presentation_mode | 49 | attr == self.presentation_mode |
50 | end | 50 | end |
51 | 51 | ||
52 | + def api_content | ||
53 | + Api::Entities::ArticleBase.represent(self.discussions).as_json | ||
54 | + end | ||
55 | + | ||
56 | + def display_api_content_by_default? | ||
57 | + false | ||
58 | + end | ||
52 | end | 59 | end |
plugins/comment_paragraph/test/unit/discussion_block_test.rb
@@ -174,4 +174,18 @@ class DiscussionBlockViewTest < ActionView::TestCase | @@ -174,4 +174,18 @@ class DiscussionBlockViewTest < ActionView::TestCase | ||
174 | 174 | ||
175 | assert_match /discussion-full/, content | 175 | assert_match /discussion-full/, content |
176 | end | 176 | end |
177 | + | ||
178 | + should 'return discussions in api_content' do | ||
179 | + community = fast_create(Community) | ||
180 | + community.boxes << Box.new | ||
181 | + b = CommentParagraphPlugin::DiscussionBlock.new | ||
182 | + b.box = community.boxes.last | ||
183 | + b.save | ||
184 | + a1 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) | ||
185 | + fast_create(Event, :profile_id => community.id) | ||
186 | + fast_create(TinyMceArticle, :profile_id => community.id) | ||
187 | + a2 = fast_create(CommentParagraphPlugin::Discussion, :profile_id => community.id) | ||
188 | + assert_equivalent [a2.id, a1.id], b.api_content['articles'].map {|a| a[:id]} | ||
189 | + end | ||
190 | + | ||
177 | end | 191 | end |