diff --git a/app/models/contract.rb b/app/models/contract.rb index c196969..0b7b006 100644 --- a/app/models/contract.rb +++ b/app/models/contract.rb @@ -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 diff --git a/app/models/deliverable.rb b/app/models/deliverable.rb new file mode 100644 index 0000000..7cf35fb --- /dev/null +++ b/app/models/deliverable.rb @@ -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 diff --git a/db/migrate/002_create_deliverables.rb b/db/migrate/002_create_deliverables.rb new file mode 100644 index 0000000..922b8e2 --- /dev/null +++ b/db/migrate/002_create_deliverables.rb @@ -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 diff --git a/test/unit/contract_test.rb b/test/unit/contract_test.rb index 715914b..aa3e7b9 100644 --- a/test/unit/contract_test.rb +++ b/test/unit/contract_test.rb @@ -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 diff --git a/test/unit/deliverable_test.rb b/test/unit/deliverable_test.rb new file mode 100644 index 0000000..e4f792c --- /dev/null +++ b/test/unit/deliverable_test.rb @@ -0,0 +1,6 @@ +require File.dirname(__FILE__) + '/../test_helper' + +class DeliverableTest < ActiveSupport::TestCase + should_belong_to :contract + should_belong_to :manager +end