@@ -447,6 +447,11 class Issue < ActiveRecord::Base | |||
|
447 | 447 | if (t = attrs.delete('tracker_id')) && safe_attribute?('tracker_id') |
|
448 | 448 | self.tracker_id = t |
|
449 | 449 | end |
|
450 | if project | |
|
451 | # Set the default tracker to accept custom field values | |
|
452 | # even if tracker is not specified | |
|
453 | self.tracker ||= project.trackers.first | |
|
454 | end | |
|
450 | 455 | |
|
451 | 456 | if (s = attrs.delete('status_id')) && safe_attribute?('status_id') |
|
452 | 457 | if new_statuses_allowed_to(user).collect(&:id).include?(s.to_i) |
@@ -406,6 +406,35 JSON | |||
|
406 | 406 | assert_equal 'API test', issue.subject |
|
407 | 407 | end |
|
408 | 408 | |
|
409 | test "POST /issues.json without tracker_id should accept custom fields" do | |
|
410 | field = IssueCustomField.generate!( | |
|
411 | :field_format => 'list', | |
|
412 | :multiple => true, | |
|
413 | :possible_values => ["V1", "V2", "V3"], | |
|
414 | :default_value => "V2", | |
|
415 | :is_for_all => true, | |
|
416 | :trackers => Tracker.all.to_a | |
|
417 | ) | |
|
418 | ||
|
419 | payload = <<-JSON | |
|
420 | { | |
|
421 | "issue": { | |
|
422 | "project_id": "1", | |
|
423 | "subject": "Multivalued custom field", | |
|
424 | "custom_field_values":{"#{field.id}":["V1","V3"]} | |
|
425 | } | |
|
426 | } | |
|
427 | JSON | |
|
428 | ||
|
429 | assert_difference('Issue.count') do | |
|
430 | post '/issues.json', payload, {"CONTENT_TYPE" => 'application/json'}.merge(credentials('jsmith')) | |
|
431 | end | |
|
432 | ||
|
433 | assert_response :created | |
|
434 | issue = Issue.order('id DESC').first | |
|
435 | assert_equal ["V1", "V3"], issue.custom_field_value(field) | |
|
436 | end | |
|
437 | ||
|
409 | 438 | test "POST /issues.json with failure should return errors" do |
|
410 | 439 | assert_no_difference('Issue.count') do |
|
411 | 440 | post '/issues.json', {:issue => {:project_id => 1}}, credentials('jsmith') |
General Comments 0
You need to be logged in to leave comments.
Login now