diff --git a/app/models/deliverable.rb b/app/models/deliverable.rb
index 003805b..fa93bf9 100644
--- a/app/models/deliverable.rb
+++ b/app/models/deliverable.rb
@@ -19,6 +19,7 @@ class Deliverable < ActiveRecord::Base
validates_presence_of :title
validates_presence_of :type
validates_presence_of :manager
+ validates_inclusion_of :status, :in => ["open","locked","closed"], :allow_blank => true, :allow_nil => true
# Accessors
include DollarizedAttribute
@@ -27,7 +28,10 @@ class Deliverable < ActiveRecord::Base
delegate :name, :to => :contract, :prefix => true, :allow_nil => true
# Callbacks
-
+ def after_initialize
+ self.status = "open" unless self.status.present?
+ end
+
# Register callbacks here, on new records the class isn't set so class-specific
# callbacks don't fire.
def after_save
diff --git a/app/views/contracts/show.html.erb b/app/views/contracts/show.html.erb
index 5c68f7f..aff2cda 100644
--- a/app/views/contracts/show.html.erb
+++ b/app/views/contracts/show.html.erb
@@ -130,7 +130,7 @@
<%= h format_date(deliverable.end_date) %> |
<%= h deliverable.short_type %> |
<%= h deliverable.title %> |
- <%= release(5, "Deliverable status") %> |
+ <%= h deliverable.status %> |
<%= h deliverable.manager.try(:name) %> |
<%= format_budget_for_deliverable(deliverable, deliverable.labor_budget_spent, deliverable.labor_budget_total, :class => 'labor') %>
<%= format_budget_for_deliverable(deliverable, deliverable.overhead_spent, deliverable.overhead_budget_total, :class => 'overhead') %>
diff --git a/app/views/deliverables/_form.html.erb b/app/views/deliverables/_form.html.erb
index 1da5da6..b824160 100644
--- a/app/views/deliverables/_form.html.erb
+++ b/app/views/deliverables/_form.html.erb
@@ -19,6 +19,7 @@
<%= form.input :type, :as => :hidden, :class => 'type' %>
<% end %>
+ <%= form.input :status, :required => true, :collection => [["Open","open"],["Locked","locked"],["Closed","closed"]] %>
<%= form.input :manager, :required => true, :collection => @project.users.sort %>
<%= form.input :start_date, :as => :string, :input_html => {:size => 10, :class => 'start-date', :id => 'deliverable_start_date'}, :hint => calendar_for('deliverable_start_date') %>
diff --git a/db/migrate/019_add_status_to_deliverables.rb b/db/migrate/019_add_status_to_deliverables.rb
new file mode 100644
index 0000000..b4dbb7d
--- /dev/null
+++ b/db/migrate/019_add_status_to_deliverables.rb
@@ -0,0 +1,10 @@
+class AddStatusToDeliverables < ActiveRecord::Migration
+ def self.up
+ add_column :deliverables, :status, :string
+ add_index :deliverables, :status
+ end
+
+ def self.down
+ remove_column :deliverables, :status
+ end
+end
diff --git a/test/integration/deliverables_edit_test.rb b/test/integration/deliverables_edit_test.rb
index 4082190..cde9edc 100644
--- a/test/integration/deliverables_edit_test.rb
+++ b/test/integration/deliverables_edit_test.rb
@@ -49,6 +49,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
within("#deliverable-details") do
fill_in "Title", :with => 'An updated title'
+ select "Locked", :from => "Status"
check "Feature Sign Off"
check "Warranty Sign Off"
end
@@ -61,6 +62,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
assert_equal "FixedDeliverable", @fixed_deliverable.reload.type
assert @fixed_deliverable.reload.warranty_sign_off?
assert @fixed_deliverable.reload.feature_sign_off?
+ assert_equal "locked", @fixed_deliverable.reload.status
end
@@ -78,6 +80,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
within("#deliverable-details") do
fill_in "Title", :with => 'An updated title'
+ select "Locked", :from => "Status"
check "Feature Sign Off"
check "Warranty Sign Off"
end
@@ -101,6 +104,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
assert_equal "HourlyDeliverable", @hourly_deliverable.reload.type
assert @hourly_deliverable.reload.warranty_sign_off?
assert @hourly_deliverable.reload.feature_sign_off?
+ assert_equal "locked", @hourly_deliverable.reload.status
assert_equal 1, @hourly_deliverable.labor_budgets.count
@labor_budget = @hourly_deliverable.labor_budgets.first
diff --git a/test/integration/deliverables_new_test.rb b/test/integration/deliverables_new_test.rb
index a55d5f8..97edac4 100644
--- a/test/integration/deliverables_new_test.rb
+++ b/test/integration/deliverables_new_test.rb
@@ -74,6 +74,7 @@ class DeliverablesNewTest < ActionController::IntegrationTest
within("#deliverable-details") do
fill_in "Title", :with => 'A New Deliverable'
select "Fixed", :from => "Type"
+ select "Locked", :from => "Status"
select @manager.name, :from => "Manager"
fill_in "Start", :with => '2010-01-01'
fill_in "End Date", :with => '2010-12-31'
@@ -95,6 +96,7 @@ class DeliverablesNewTest < ActionController::IntegrationTest
assert_equal '2010-12-31', @deliverable.end_date.to_s
assert_equal @manager, @deliverable.manager
assert_equal 1000.0, @deliverable.total.to_f
+ assert_equal "locked", @deliverable.status
end
should "create a new Hourly deliverable" do
@@ -109,6 +111,7 @@ class DeliverablesNewTest < ActionController::IntegrationTest
within("#deliverable-details") do
fill_in "Title", :with => 'A New Deliverable'
select "Hourly", :from => "Type"
+ select "Locked", :from => "Status"
select @manager.name, :from => "Manager"
fill_in "Start", :with => '2010-01-01'
fill_in "End Date", :with => '2010-12-31'
@@ -128,7 +131,8 @@ class DeliverablesNewTest < ActionController::IntegrationTest
assert_equal '2010-01-01', @deliverable.start_date.to_s
assert_equal '2010-12-31', @deliverable.end_date.to_s
assert_equal @manager, @deliverable.manager
-
+ assert_equal "locked", @deliverable.status
+
end
should "create a new Retainer deliverable" do
@@ -143,6 +147,7 @@ class DeliverablesNewTest < ActionController::IntegrationTest
within("#deliverable-details") do
fill_in "Title", :with => 'A New Deliverable'
select "Retainer", :from => "Type"
+ select "Locked", :from => "Status"
select @manager.name, :from => "Manager"
fill_in "Start", :with => '2010-01-01'
fill_in "End Date", :with => '2010-12-31'
@@ -171,7 +176,8 @@ class DeliverablesNewTest < ActionController::IntegrationTest
assert_equal '2010-01-01', @deliverable.start_date.to_s
assert_equal '2010-12-31', @deliverable.end_date.to_s
assert_equal @manager, @deliverable.manager
-
+ assert_equal "locked", @deliverable.status
+
# Budget items, one per month
labor_budgets = @deliverable.labor_budgets
assert_equal 12, labor_budgets.length
diff --git a/test/unit/deliverable_test.rb b/test/unit/deliverable_test.rb
index 694adc0..4cd7965 100644
--- a/test/unit/deliverable_test.rb
+++ b/test/unit/deliverable_test.rb
@@ -12,6 +12,13 @@ class DeliverableTest < ActiveSupport::TestCase
should_validate_presence_of :type
should_validate_presence_of :manager
+ should_allow_values_for :status, "", nil, 'open', 'locked', 'closed'
+ should_not_allow_values_for :status, "other", "things", "1"
+
+ should "default status to open" do
+ assert_equal "open", Deliverable.new.status
+ end
+
context "#total=" do
should "strip dollar signs when writing" do
d = Deliverable.new