fixes budget creation

We need to provide the new labor_budget_item with a cost object. Otherwise checking the can_view_costs permission check will break.
pull/6827/head
Jens Ulferts 12 years ago
parent d2c281cb4a
commit b4cc859139
  1. 7
      app/views/cost_objects/_form.rhtml
  2. 24
      features/create_budget.feature
  3. 19
      features/support/path.rb

@ -21,7 +21,12 @@
<script type="text/javascript">
//<![CDATA[
materialBudgetItemsForm = new Subform('<%= escape_javascript(render(:partial => "material_budget_item", :object => @cost_object.material_budget_items.build(:cost_type => CostType.default) )) %>',<%= @cost_object.material_budget_items.length %>,'material_budget_items_body');
laborBudgetItemsForm = new Subform('<%= escape_javascript(render(:partial => "labor_budget_item", :object => @cost_object.labor_budget_items.build )) %>',<%= @cost_object.labor_budget_items.length %>,'labor_budget_items_body');
<%# we have to assign the cost_object here as following methods depend on the item having an object -%>
<% item = @cost_object.labor_budget_items.build.tap do |i|
i.cost_object = @cost_object
end -%>
laborBudgetItemsForm = new Subform('<%= escape_javascript(render(:partial => "labor_budget_item", :object => item )) %>',<%= @cost_object.labor_budget_items.length %>,'labor_budget_items_body');
//]]>
</script>

@ -0,0 +1,24 @@
Feature: Creating a Budget
Scenario: Budgets can be created
Given there is 1 User with:
| Login | testuser |
And there is 1 Project with the following:
| name | project1 |
| identifier | project1 |
And there is a role "manager"
And the role "manager" may have the following rights:
| edit_cost_objects |
And the user "testuser" is a "manager" in the project "project1"
And I am already logged in as "testuser"
When I go to the overview page of the project called "project1"
And I follow "Budgets" within "#main-menu"
And I follow "New Budget" within "#main-menu"
And I fill in "cost_object_subject" with "budget1"
And I press "Create"
Then I should be on the show page for the budget "budget1"
And I should see "Successful creation"
And I should see "budget1" within ".cost_object"

@ -0,0 +1,19 @@
module CostNavigationHelpers
# Maps a name to a path. Used by the
#
# When /^I go to (.+)$/ do |page_name|
#
# step definition in web_steps.rb
#
def path_to(page_name)
case page_name
when /^the show page (?:of|for) the budget "(.+)?"$/
budget = CostObject.find_by_subject($1)
"/cost_objects/#{budget.id}"
else
super
end
end
end
World(CostNavigationHelpers)
Loading…
Cancel
Save