##// END OF EJS Templates
Prevent NoMethodError on nil class if custom_fields params is not present in IssuesController#new (#969)....
Jean-Philippe Lang -
r1302:e4da9d6f10ed
parent child
Show More
@@ -140,7 +140,9 class IssuesController < ApplicationController
140 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
140 requested_status = IssueStatus.find_by_id(params[:issue][:status_id])
141 # Check that the user is allowed to apply the requested status
141 # Check that the user is allowed to apply the requested status
142 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
142 @issue.status = (@allowed_statuses.include? requested_status) ? requested_status : default_status
143 @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]) }
143 @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| CustomValue.new(:custom_field => x,
144 :customized => @issue,
145 :value => (params[:custom_fields] ? params[:custom_fields][x.id.to_s] : nil)) }
144 @issue.custom_values = @custom_values
146 @issue.custom_values = @custom_values
145 if @issue.save
147 if @issue.save
146 attach_files(@issue, params[:attachments])
148 attach_files(@issue, params[:attachments])
@@ -181,6 +181,16 class IssuesControllerTest < Test::Unit::TestCase
181 assert_equal 'Value for field 2', v.value
181 assert_equal 'Value for field 2', v.value
182 end
182 end
183
183
184 def test_post_new_without_custom_fields_param
185 @request.session[:user_id] = 2
186 post :new, :project_id => 1,
187 :issue => {:tracker_id => 1,
188 :subject => 'This is the test_new issue',
189 :description => 'This is the description',
190 :priority_id => 5}
191 assert_redirected_to 'issues/show'
192 end
193
184 def test_copy_issue
194 def test_copy_issue
185 @request.session[:user_id] = 2
195 @request.session[:user_id] = 2
186 get :new, :project_id => 1, :copy_from => 1
196 get :new, :project_id => 1, :copy_from => 1
General Comments 0
You need to be logged in to leave comments. Login now