Commit 83f48698f6f8aff8cf7a6f8eaa708b844f78dafa
1 parent
1abaaf1a
Exists in
master
and in
29 other branches
ActionItem96: creating task class
git-svn-id: https://svn.colivre.coop.br/svn/noosfero/trunk@610 3f533792-8f58-4932-b0fe-aaf55b0a4547
Showing
3 changed files
with
44 additions
and
0 deletions
Show diff stats
| ... | ... | @@ -0,0 +1,16 @@ |
| 1 | +class CreateTasks < ActiveRecord::Migration | |
| 2 | + def self.up | |
| 3 | + create_table :tasks do |t| | |
| 4 | + | |
| 5 | + t.column :data, :text | |
| 6 | + t.column :status, :integer | |
| 7 | + | |
| 8 | + t.column :requestor_id, :integer | |
| 9 | + t.column :target_id, :integer | |
| 10 | + end | |
| 11 | + end | |
| 12 | + | |
| 13 | + def self.down | |
| 14 | + drop_table :tasks | |
| 15 | + end | |
| 16 | +end | ... | ... |
| ... | ... | @@ -0,0 +1,24 @@ |
| 1 | +require File.dirname(__FILE__) + '/../test_helper' | |
| 2 | + | |
| 3 | +class TaskTest < Test::Unit::TestCase | |
| 4 | + | |
| 5 | + def test_relationship_with_requestor | |
| 6 | + t = Task.new | |
| 7 | + assert_raise ActiveRecord::AssociationTypeMismatch do | |
| 8 | + t.requestor = 1 | |
| 9 | + end | |
| 10 | + assert_nothing_raised do | |
| 11 | + t.requestor = Profile.new | |
| 12 | + end | |
| 13 | + end | |
| 14 | + | |
| 15 | + def test_relationship_with_target | |
| 16 | + t = Task.new | |
| 17 | + assert_raise ActiveRecord::AssociationTypeMismatch do | |
| 18 | + t.target = 1 | |
| 19 | + end | |
| 20 | + assert_nothing_raised do | |
| 21 | + t.target = Profile.new | |
| 22 | + end | |
| 23 | + end | |
| 24 | +end | ... | ... |