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