[#4181] Require a Deliverable's title, type, and manager.
This commit is contained in:
@@ -6,10 +6,24 @@ class Deliverable < ActiveRecord::Base
|
||||
belongs_to :manager, :class_name => 'User', :foreign_key => 'manager_id'
|
||||
|
||||
# Validations
|
||||
|
||||
validates_presence_of :title
|
||||
validates_presence_of :type
|
||||
validates_presence_of :manager
|
||||
|
||||
# Accessors
|
||||
|
||||
def short_type
|
||||
''
|
||||
end
|
||||
|
||||
if Rails.env.test?
|
||||
generator_for :title, :method => :next_title
|
||||
|
||||
def self.next_title
|
||||
@last_title ||= 'Deliverable 0000'
|
||||
@last_title.succ!
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<% form.inputs do %>
|
||||
<%= form.input :title, :required => true %>
|
||||
<%= form.input :type, :required => true, :as => :select, :collection => [["Fixed", "FixedDeliverable"]] %>
|
||||
<%= form.input :manager %>
|
||||
<%= form.input :manager, :required => true %>
|
||||
<%= form.input :start_date, :as => :string, :input_html => {:size => 10}, :hint => calendar_for('deliverable_start_date') %>
|
||||
<%= form.input :end_date, :as => :string, :input_html => {:size => 10}, :hint => calendar_for('deliverable_end_date') %>
|
||||
<%= form.input :notes, :input_html => {:class => 'wiki-edit', :rows => '5'} %>
|
||||
|
||||
@@ -3,4 +3,8 @@ require File.dirname(__FILE__) + '/../test_helper'
|
||||
class DeliverableTest < ActiveSupport::TestCase
|
||||
should_belong_to :contract
|
||||
should_belong_to :manager
|
||||
|
||||
should_validate_presence_of :title
|
||||
should_validate_presence_of :type
|
||||
should_validate_presence_of :manager
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user