[#4177] Added Deliverable and it's associations.

This commit is contained in:
Eric Davis
2010-06-17 13:41:49 -07:00
parent 512db4bcf4
commit 0695eb3e8e
5 changed files with 44 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ class Contract < ActiveRecord::Base
# Associations
belongs_to :project
belongs_to :account_executive, :class_name => 'User', :foreign_key => 'account_executive_id'
has_many :deliverables
# Validations
validates_presence_of :name

11
app/models/deliverable.rb Normal file
View File

@@ -0,0 +1,11 @@
class Deliverable < ActiveRecord::Base
unloadable
# Associations
belongs_to :contract
belongs_to :manager, :class_name => 'User', :foreign_key => 'manager_id'
# Validations
# Accessors
end

View File

@@ -0,0 +1,25 @@
class CreateDeliverables < ActiveRecord::Migration
def self.up
create_table :deliverables do |t|
t.string :title
t.string :type
t.date :start_date
t.date :end_date
t.notes :text
t.boolean :feature_sign_off
t.boolean :warranty_sign_off
t.integer :manager_id # User
t.references :contract
end
add_index :deliverables, :title
add_index :deliverables, :type
add_index :deliverables, :start_date
add_index :deliverables, :end_date
add_index :deliverables, :contract_id
end
def self.down
drop_table :deliverables
end
end

View File

@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper'
class ContractTest < ActiveSupport::TestCase
should_belong_to :account_executive
should_belong_to :project
should_have_many :deliverables
should_validate_presence_of :name
should_validate_presence_of :account_executive

View File

@@ -0,0 +1,6 @@
require File.dirname(__FILE__) + '/../test_helper'
class DeliverableTest < ActiveSupport::TestCase
should_belong_to :contract
should_belong_to :manager
end