allow_comment_test.rb
1.47 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require File.dirname(__FILE__) + '/../test_helper'
class AllowCommentTest < ActiveSupport::TestCase
def setup
@macro = CommentParagraphPlugin::AllowComment.new
end
attr_reader :macro
should 'have a configuration' do
assert CommentParagraphPlugin::AllowComment.configuration
end
should 'parse contents to include comment paragraph view' do
profile = fast_create(Community)
article = fast_create(Article, :profile_id => profile.id)
comment = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id)
inner_html = 'inner'
content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, inner_html, article)
expects(:controller).returns(ContentViewerController.new)
expects(:render).with({:partial => 'comment_paragraph_plugin_profile/comment_paragraph', :locals => {:paragraph_uuid => comment.paragraph_uuid, :article_id => article.id, :inner_html => inner_html, :count => 1, :profile_identifier => profile.identifier} })
instance_eval(&content)
end
should 'not parse contents outside content viewer controller' do
profile = fast_create(Community)
article = fast_create(Article, :profile_id => profile.id)
comment = fast_create(Comment, :paragraph_uuid => 1, :source_id => article.id)
inner_html = 'inner'
content = macro.parse({:paragraph_uuid => comment.paragraph_uuid}, inner_html, article)
expects(:controller).returns(HomeController.new)
assert_equal 'inner', instance_eval(&content)
end
end