From b4cc8591390a3ca2f0f6e3de8a7e7b1040f335c7 Mon Sep 17 00:00:00 2001 From: Jens Ulferts Date: Fri, 15 Mar 2013 09:27:58 +0100 Subject: [PATCH] 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. --- app/views/cost_objects/_form.rhtml | 7 ++++++- features/create_budget.feature | 24 ++++++++++++++++++++++++ features/support/path.rb | 19 +++++++++++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 features/create_budget.feature create mode 100644 features/support/path.rb diff --git a/app/views/cost_objects/_form.rhtml b/app/views/cost_objects/_form.rhtml index d56a0716af..4f57ec766e 100644 --- a/app/views/cost_objects/_form.rhtml +++ b/app/views/cost_objects/_form.rhtml @@ -21,7 +21,12 @@ diff --git a/features/create_budget.feature b/features/create_budget.feature new file mode 100644 index 0000000000..d734335210 --- /dev/null +++ b/features/create_budget.feature @@ -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" + diff --git a/features/support/path.rb b/features/support/path.rb new file mode 100644 index 0000000000..507f304093 --- /dev/null +++ b/features/support/path.rb @@ -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)