Commit e6e26d291ed312a36c0a7e501828c837755b8465

Authored by Michel Felipe
2 parents e82b6d44 d53f4973

Merge branch 'proposal_task_category' of gitlab.com:noosfero-plugins/proposals_d…

…iscussion into proposal_task_category
lib/proposals_discussion_plugin/proposal_task.rb
1 1 class ProposalsDiscussionPlugin::ProposalTask < Task
2 2  
  3 + has_and_belongs_to_many :proposals_discussion_plugin_task_categories
  4 +
3 5 validates_presence_of :requestor_id, :target_id
4 6 validates_associated :article_object
5 7  
... ...
lib/proposals_discussion_plugin/task_category.rb 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +class ProposalsDiscussionPlugin::TaskCategory < Category
  2 +
  3 + has_and_belongs_to_many :tasks
  4 +end
... ...
test/unit/task_category_test.rb 0 → 100644
... ... @@ -0,0 +1,29 @@
  1 +require_relative '../test_helper'
  2 +
  3 +class TaskCategory < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + @person = fast_create(Person)
  7 + @profile = fast_create(Community)
  8 + @discussion = ProposalsDiscussionPlugin::Discussion.create!(:name => 'discussion', :profile => @person, :name => 'discussion')
  9 + @proposal = ProposalsDiscussionPlugin::Proposal.create!(:name => 'test', :abstract => 'abstract', :profile => @profile, :parent => @discussion)
  10 + end
  11 +
  12 + attr_reader :person, :profile, :discussion, :proposal
  13 +
  14 + should 'add a category to a task' do
  15 + requestor = fast_create(Person)
  16 + task_data = {
  17 + :requestor => requestor,
  18 + :target => person,
  19 + :spam => false
  20 + }
  21 +
  22 + task = Task.create!(task_data)
  23 +
  24 + category = ProposalsDiscussionPlugin::TaskCategory.create!(name: 'ProposalTest', tasks: [task])
  25 +
  26 + assert_equal task.id, category.tasks[0].id
  27 + end
  28 +
  29 +end
... ...