Commit d53f4973fdc4e1ecd62825814ef4175bb62661ab
1 parent
be87834e
Exists in
master
and in
8 other branches
Changed structure to add categories into tasks of type proposal. Need's check unit tests problems
Showing
3 changed files
with
35 additions
and
0 deletions
Show diff stats
lib/proposals_discussion_plugin/proposal_task.rb
| 1 | class ProposalsDiscussionPlugin::ProposalTask < Task | 1 | class ProposalsDiscussionPlugin::ProposalTask < Task |
| 2 | 2 | ||
| 3 | + has_and_belongs_to_many :proposals_discussion_plugin_task_categories | ||
| 4 | + | ||
| 3 | validates_presence_of :requestor_id, :target_id | 5 | validates_presence_of :requestor_id, :target_id |
| 4 | validates_associated :article_object | 6 | validates_associated :article_object |
| 5 | 7 |
| @@ -0,0 +1,29 @@ | @@ -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 |