topic_test.rb
1.91 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
require File.dirname(__FILE__) + '/../test_helper'
class TopicTest < ActiveSupport::TestCase
def setup
@profile = fast_create(Community)
@topic = ProposalsDiscussionPlugin::Topic.new(:name => 'test', :profile => @profile)
end
attr_reader :profile, :topic
should 'return list of proposals' do
topic.save!
proposal1 = fast_create(ProposalsDiscussionPlugin::Proposal, :parent_id => topic.id)
proposal2 = fast_create(ProposalsDiscussionPlugin::Proposal, :parent_id => topic.id)
assert_equivalent [proposal1, proposal2], topic.proposals
end
should 'allow any user to create proposals in a topic' do
assert topic.allow_create?(Person.new)
end
should 'return list of comments' do
topic.save!
proposal = fast_create(ProposalsDiscussionPlugin::Proposal, :parent_id => topic.id)
comment1 = fast_create(Comment, :source_id => proposal.id)
comment2 = fast_create(Comment, :source_id => proposal.id)
assert_equivalent [comment1, comment2], topic.proposals_comments
end
should 'return list of authors' do
topic.save!
author1 = fast_create(Person)
author2 = fast_create(Person)
fast_create(ProposalsDiscussionPlugin::Proposal, :parent_id => topic.id, :created_by_id => author1)
fast_create(ProposalsDiscussionPlugin::Proposal, :parent_id => topic.id, :created_by_id => author2)
assert_equivalent [author1, author2], topic.proposals_authors
end
should 'return most active participants' do
topic.save!
author1 = fast_create(Person)
author2 = fast_create(Person)
fast_create(ProposalsDiscussionPlugin::Proposal, :parent_id => topic.id, :created_by_id => author1)
fast_create(ProposalsDiscussionPlugin::Proposal, :parent_id => topic.id, :created_by_id => author2)
fast_create(ProposalsDiscussionPlugin::Proposal, :parent_id => topic.id, :created_by_id => author2)
assert_equal [author2, author1], topic.most_active_participants
end
end