[#4177] Added Deliverable and it's associations.
This commit is contained in:
1 parent
512db4bcf4
commit
0695eb3e8e
5 files changed
+44
No files matched your search
@@ -4,6 +4,7 @@ class Contract < ActiveRecord::Base
|
|||||||
# Associations
|
# Associations
|
||||||
belongs_to :project
|
belongs_to :project
|
||||||
belongs_to :account_executive, :class_name => 'User', :foreign_key => 'account_executive_id'
|
belongs_to :account_executive, :class_name => 'User', :foreign_key => 'account_executive_id'
|
||||||
|
has_many :deliverables
|
||||||
|
|
||||||
# Validations
|
# Validations
|
||||||
validates_presence_of :name
|
validates_presence_of :name
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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
|
||||||
@@ -3,6 +3,7 @@ require File.dirname(__FILE__) + '/../test_helper'
|
|||||||
class ContractTest < ActiveSupport::TestCase
|
class ContractTest < ActiveSupport::TestCase
|
||||||
should_belong_to :account_executive
|
should_belong_to :account_executive
|
||||||
should_belong_to :project
|
should_belong_to :project
|
||||||
|
should_have_many :deliverables
|
||||||
|
|
||||||
should_validate_presence_of :name
|
should_validate_presence_of :name
|
||||||
should_validate_presence_of :account_executive
|
should_validate_presence_of :account_executive
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
require File.dirname(__FILE__) + '/../test_helper'
|
||||||
|
|
||||||
|
class DeliverableTest < ActiveSupport::TestCase
|
||||||
|
should_belong_to :contract
|
||||||
|
should_belong_to :manager
|
||||||
|
end
|
||||||
Reference in new issue
Block a user