comment_group_plugin_test.rb
2.98 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
require File.dirname(__FILE__) + '/../../../../test/test_helper'
class CommentGroupPluginTest < ActiveSupport::TestCase
include Noosfero::Plugin::HotSpot
def setup
@environment = Environment.default
end
attr_reader :environment
should 'register comment_group_macro in environment' do
Environment.macros = {}
Environment.macros[environment.id] = {}
macros = Environment.macros[environment.id]
context = mock()
context.stubs(:environment).returns(environment)
plugin = CommentGroupPlugin.new(context)
assert_equal ['macro_display_comments'], macros.keys
end
should 'load_comments returns all the comments wihout group of an article passed as parameter' do
article = fast_create(Article)
c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)
c2 = fast_create(Comment, :source_id => article.id)
c3 = fast_create(Comment, :source_id => article.id)
plugin = CommentGroupPlugin.new
assert_equal [], [c2, c3] - plugin.load_comments(article)
assert_equal [], plugin.load_comments(article) - [c2, c3]
end
should 'load_comments not returns spam comments' do
article = fast_create(Article)
c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)
c2 = fast_create(Comment, :source_id => article.id)
c3 = fast_create(Comment, :source_id => article.id, :spam => true)
plugin = CommentGroupPlugin.new
assert_equal [], [c2] - plugin.load_comments(article)
assert_equal [], plugin.load_comments(article) - [c2]
end
should 'load_comments returns only root comments of article' do
article = fast_create(Article)
c1 = fast_create(Comment, :source_id => article.id, :group_id => 1)
c2 = fast_create(Comment, :source_id => article.id)
c3 = fast_create(Comment, :source_id => article.id, :reply_of_id => c2.id)
plugin = CommentGroupPlugin.new
assert_equal [], [c2] - plugin.load_comments(article)
assert_equal [], plugin.load_comments(article) - [c2]
end
should 'params of macro display comments configuration be an empty array' do
plugin = CommentGroupPlugin.new
assert_equal [], plugin.config_macro_display_comments[:params]
end
should 'skip_dialog of macro display comments configuration be true' do
plugin = CommentGroupPlugin.new
assert plugin.config_macro_display_comments[:skip_dialog]
end
should 'generator of macro display comments configuration be the makeCommentable function' do
plugin = CommentGroupPlugin.new
assert_equal 'makeCommentable();', plugin.config_macro_display_comments[:generator]
end
should 'js_files of macro display comments configuration return comment_group.js' do
plugin = CommentGroupPlugin.new
assert_equal 'comment_group.js', plugin.config_macro_display_comments[:js_files]
end
should 'css_files of macro display comments configuration return comment_group.css' do
plugin = CommentGroupPlugin.new
assert_equal 'comment_group.css', plugin.config_macro_display_comments[:css_files]
end
end