fix the creation of workpackages, when a validation-error occurs

added missing :locals to the render-call of create; fixed the
highlighting in the menue for workpackages.
pull/429/head
Stefan Frank 11 years ago
parent acc7343a7c
commit 795b228b5f
  1. 20
      app/controllers/work_packages_controller.rb
  2. 57
      features/work_packages/create.feature
  3. 4
      lib/redmine.rb

@ -15,25 +15,14 @@ class WorkPackagesController < ApplicationController
DEFAULT_SORT_ORDER = ['parent', 'desc']
EXPORT_FORMATS = %w[atom rss xls csv pdf]
menu_item :new_work_package, :only => [:new, :create]
include QueriesHelper
include SortHelper
include PaginationHelper
accept_key_auth :index, :show, :create, :update, :destroy
current_menu_item do |controller|
begin
wp = controller.work_package
case wp
when Issue
:issues
end
rescue
:issues
end
end
before_filter :disable_api
before_filter :not_found_unless_work_package,
:project,
@ -132,7 +121,10 @@ class WorkPackagesController < ApplicationController
redirect_to(work_package_path(work_package))
else
respond_to do |format|
format.html { render :action => 'new' }
format.html { render :action => 'new', :locals => { :work_package => work_package,
:project => project,
:priorities => priorities,
:user => current_user } }
end
end
end

@ -0,0 +1,57 @@
#-- copyright
# OpenProject is a project management system.
#
# Copyright (C) 2012-2013 the OpenProject Team
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License version 3.
#
# See doc/COPYRIGHT.rdoc for more details.
#++
Feature: Creating work packages
Background:
Given there is 1 user with:
| login | manager |
| firstname | the |
| lastname | manager |
And there are the following types:
| Name | Is milestone |
| Phase1 | false |
| Phase2 | false |
And there are the following project types:
| Name |
| Standard Project |
And there is 1 project with the following:
| identifier | ecookbook |
| name | ecookbook |
And the project named "ecookbook" is of the type "Standard Project"
And the following types are enabled for projects of type "Standard Project"
| Phase1 |
| Phase2 |
And I am working in project "ecookbook"
And there is a role "manager"
And the role "manager" may have the following rights:
| add_work_packages |
| create_work_packages |
| edit_work_packages |
| view_work_packages |
| manage_subtasks |
And the user "manager" is a "manager" in the project "ecookbook"
And there are the following priorities:
| name | default |
| prio1 | true |
| prio2 | |
And there are the following status:
| name | default |
| status1 | true |
| status2 | |
And the type "Phase1" has the default workflow for the role "manager"
And the type "Phase2" has the default workflow for the role "manager"
And I am already logged in as "manager"
@javascript
Scenario: Creating a new work package without required fields should give an error-message
When I go to the new work_package page of the project called "ecookbook"
And I submit the form by the "Create" button
Then I should see "Subject can't be blank" within "#errorExplanation"

@ -273,8 +273,8 @@ Redmine::MenuManager.map :project_menu do |menu|
:if => Proc.new { |p| p.shared_versions.any? }
menu.push :work_packages, { :controller => '/work_packages', :action => 'index' }, :param => :project_id, :caption => :label_work_package_plural
menu.push :new_issue, { :controller => '/work_packages', :action => 'new', :sti_type => 'Issue' }, :param => :project_id, :caption => :label_work_package_new, :parent => :work_packages,
:html => { :accesskey => Redmine::AccessKeys.key_for(:new_issue) }
menu.push :new_work_package, { :controller => '/work_packages', :action => 'new'}, :param => :project_id, :caption => :label_work_package_new, :parent => :work_packages,
:html => { :accesskey => Redmine::AccessKeys.key_for(:new_work_package) }
menu.push :view_all_work_packages, { :controller => '/work_packages', :action => 'index', :set_filter => 1 }, :param => :project_id, :caption => :label_work_package_view_all, :parent => :work_packages
menu.push :summary_field, {:controller => '/issues/reports', :action => 'report'}, :param => :project_id, :caption => :label_workflow_summary, :parent => :work_packages
menu.push :calendar, { :controller => '/issues/calendars', :action => 'index' }, :param => :project_id, :caption => :label_calendar

Loading…
Cancel
Save