<%# TODO: Select field for the Time Entry Activity in a td %>
@@ -32,6 +34,8 @@
<% form.fields_for :overhead_budgets, overhead_budgets do |overhead_budget| %>
+ <%= overhead_budget.hidden_field(:year) %>
+ <%= overhead_budget.hidden_field(:month) %>
<%# TODO: Select field for the Time Entry Activity in a td %>
|
diff --git a/app/views/deliverables/_form.html.erb b/app/views/deliverables/_form.html.erb
index 6f75c71..32c3bc7 100644
--- a/app/views/deliverables/_form.html.erb
+++ b/app/views/deliverables/_form.html.erb
@@ -30,10 +30,10 @@
<% if resource.retainer? %>
<% resource.months.each do |month| %>
-<%= render :partial => 'finance_form', :locals => {:form => form, :labor_budgets => resource.labor_budgets_for_date(month), :overhead_budgets => resource.overhead_budgets_for_date(month), :label => l(:text_deliverable_finances_date, :date => month.strftime("%B, %Y")) } %>
+<%= render :partial => 'finance_form', :locals => {:form => form, :labor_budgets => resource.labor_budgets_for_date(month), :overhead_budgets => resource.overhead_budgets_for_date(month), :label => l(:text_deliverable_finances_date, :date => month.strftime("%B, %Y")), :fieldset_class => 'date-' + month.strftime('%Y-%m') } %>
<% end %>
<% else %>
-<%= render :partial => 'finance_form', :locals => {:form => form, :labor_budgets => resource.labor_budgets, :overhead_budgets => resource.overhead_budgets, :label => l(:text_deliverable_finances) } %>
+<%= render :partial => 'finance_form', :locals => {:form => form, :labor_budgets => resource.labor_budgets, :overhead_budgets => resource.overhead_budgets, :label => l(:text_deliverable_finances), :fieldset_class => '' } %>
<% end %>
diff --git a/test/integration/deliverables_edit_test.rb b/test/integration/deliverables_edit_test.rb
index cbbf27b..410a88e 100644
--- a/test/integration/deliverables_edit_test.rb
+++ b/test/integration/deliverables_edit_test.rb
@@ -91,7 +91,7 @@ class DeliverablesEditTest < ActionController::IntegrationTest
assert_equal 1000.0, @overhead_budget.budget
end
- should "show a Deliverable Finances section for each Retainer period" do
+ should "show allow editing the Deliverable Finances section for each Retainer period" do
@retainer_deliverable = RetainerDeliverable.spawn(:contract => @contract, :manager => @manager, :title => "Retainer")
@retainer_deliverable.labor_budgets << @labor_budget = LaborBudget.spawn(:deliverable => @retainer_deliverable, :budget => 1000, :hours => 10)
@retainer_deliverable.overhead_budgets << @overhead_budget = OverheadBudget.spawn(:deliverable => @retainer_deliverable, :budget => 1000, :hours => 10)
@@ -106,5 +106,56 @@ class DeliverablesEditTest < ActionController::IntegrationTest
assert_template 'deliverables/edit'
assert_select 'fieldset.deliverable-finances', :count => 12
+
+ within ".date-2010-01" do
+ within "#deliverable-labor" do
+ fill_in "hrs", :with => '20'
+ fill_in "$", :with => '2000'
+ end
+
+ within "#deliverable-overhead" do
+ fill_in "hrs", :with => '100'
+ fill_in "$", :with => '100'
+ end
+ end
+
+ click_button "Save"
+ assert_response :success
+ assert_template 'contracts/show'
+
+ @labor_budgets = @retainer_deliverable.reload.labor_budgets
+ assert_equal 12, @labor_budgets.length
+ @labor_budgets.each do |labor_budget|
+ if labor_budget.year == 2010 && labor_budget.month == 1
+
+ # Specific month's budget updated?
+ assert_equal 20.0, labor_budget.hours
+ assert_equal 2000.0, labor_budget.budget
+
+ else
+
+ assert_equal 10.0, labor_budget.hours
+ assert_equal 1000.0, labor_budget.budget
+
+ end
+ end
+
+ @overhead_budgets = @retainer_deliverable.reload.overhead_budgets
+ assert_equal 12, @overhead_budgets.length
+ @overhead_budgets.each do |overhead_budget|
+ if overhead_budget.year == 2010 && overhead_budget.month == 1
+
+ # Specific month's budget updated?
+ assert_equal 100.0, overhead_budget.hours
+ assert_equal 100.0, overhead_budget.budget
+
+ else
+
+ assert_equal 10.0, overhead_budget.hours
+ assert_equal 1000.0, overhead_budget.budget
+
+ end
+ end
+
end
end
| |