[#4177] Added Deliverable and it's associations.
This commit is contained in:
@@ -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
11
app/models/deliverable.rb
Normal 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
|
||||
25
db/migrate/002_create_deliverables.rb
Normal file
25
db/migrate/002_create_deliverables.rb
Normal 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
|
||||
@@ -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
|
||||
|
||||
6
test/unit/deliverable_test.rb
Normal file
6
test/unit/deliverable_test.rb
Normal file
@@ -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