Commit e4da9d6f authored by Jean-Philippe Lang's avatar Jean-Philippe Lang

Prevent NoMethodError on nil class if custom_fields params is not present in…

Prevent NoMethodError on nil class if custom_fields params is not present in IssuesController#new (#969).

git-svn-id: http://redmine.rubyforge.org/svn/trunk@1317 e93f8b46-1217-0410-a6f0-8f06a7374b81
parent 80a5ad7f
......@@ -140,7 +140,9 @@ class IssuesController < ApplicationController
requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
# Check that the user is allowed to apply the requested status
@issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x, :customized => @issue, :value => params["custom_fields"][x.id.to_s]) }
@custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x,
:customized => @issue,
:value => (params[:custom_fields] ? params[:custom_fields][x.id.to_s] : nil)) }
@issue.custom_values = @custom_values
if @issue.save
attach_files(@issue, params[:attachments])
......
......@@ -181,6 +181,16 @@ class IssuesControllerTest < Test::Unit::TestCase
assert_equal 'Value for field 2', v.value
end
def test_post_new_without_custom_fields_param
@request.session[:user_id] = 2
post :new, :project_id => 1,
:issue => {:tracker_id => 1,
:subject => 'This is the test_new issue',
:description => 'This is the description',
:priority_id => 5}
assert_redirected_to 'issues/show'
end
def test_copy_issue
@request.session[:user_id] = 2
get :new, :project_id => 1, :copy_from => 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment