@@ -229,6 +229,7 class Issue < ActiveRecord::Base | |||||
229 | done_ratio |
|
229 | done_ratio | |
230 | estimated_hours |
|
230 | estimated_hours | |
231 | custom_field_values |
|
231 | custom_field_values | |
|
232 | custom_fields | |||
232 | lock_version |
|
233 | lock_version | |
233 | ) unless const_defined?(:SAFE_ATTRIBUTES) |
|
234 | ) unless const_defined?(:SAFE_ATTRIBUTES) | |
234 |
|
235 |
@@ -54,7 +54,7 issues_003: | |||||
54 | author_id: 2 |
|
54 | author_id: 2 | |
55 | status_id: 1 |
|
55 | status_id: 1 | |
56 | start_date: <%= 1.day.from_now.to_date.to_s(:db) %> |
|
56 | start_date: <%= 1.day.from_now.to_date.to_s(:db) %> | |
57 |
due_date: <%= 40.day. |
|
57 | due_date: <%= 40.day.from_now.to_date.to_s(:db) %> | |
58 | root_id: 3 |
|
58 | root_id: 3 | |
59 | lft: 1 |
|
59 | lft: 1 | |
60 | rgt: 2 |
|
60 | rgt: 2 |
@@ -284,6 +284,23 class ApiTest::IssuesTest < ActionController::IntegrationTest | |||||
284 |
|
284 | |||
285 | end |
|
285 | end | |
286 |
|
286 | |||
|
287 | context "PUT /issues/3.xml with custom fields" do | |||
|
288 | setup do | |||
|
289 | @parameters = {:issue => {:custom_fields => [{'id' => '1', 'value' => 'PostgreSQL' }, {'id' => '2', 'value' => '150'}]}} | |||
|
290 | @headers = { :authorization => credentials('jsmith') } | |||
|
291 | end | |||
|
292 | ||||
|
293 | should "update custom fields" do | |||
|
294 | assert_no_difference('Issue.count') do | |||
|
295 | put '/issues/3.xml', @parameters, @headers | |||
|
296 | end | |||
|
297 | ||||
|
298 | issue = Issue.find(3) | |||
|
299 | assert_equal '150', issue.custom_value_for(2).value | |||
|
300 | assert_equal 'PostgreSQL', issue.custom_value_for(1).value | |||
|
301 | end | |||
|
302 | end | |||
|
303 | ||||
287 | context "PUT /issues/6.xml with failed update" do |
|
304 | context "PUT /issues/6.xml with failed update" do | |
288 | setup do |
|
305 | setup do | |
289 | @parameters = {:issue => {:subject => ''}} |
|
306 | @parameters = {:issue => {:subject => ''}} |
@@ -50,6 +50,21 module Redmine | |||||
50 | :order => 'position') |
|
50 | :order => 'position') | |
51 | end |
|
51 | end | |
52 |
|
52 | |||
|
53 | # Sets the values of the object's custom fields | |||
|
54 | # values is an array like [{'id' => 1, 'value' => 'foo'}, {'id' => 2, 'value' => 'bar'}] | |||
|
55 | def custom_fields=(values) | |||
|
56 | values_to_hash = values.inject({}) do |hash, v| | |||
|
57 | v = v.stringify_keys | |||
|
58 | if v['id'] && v.has_key?('value') | |||
|
59 | hash[v['id']] = v['value'] | |||
|
60 | end | |||
|
61 | hash | |||
|
62 | end | |||
|
63 | self.custom_field_values = values_to_hash | |||
|
64 | end | |||
|
65 | ||||
|
66 | # Sets the values of the object's custom fields | |||
|
67 | # values is a hash like {'1' => 'foo', 2 => 'bar'} | |||
53 | def custom_field_values=(values) |
|
68 | def custom_field_values=(values) | |
54 | @custom_field_values_changed = true |
|
69 | @custom_field_values_changed = true | |
55 | values = values.stringify_keys |
|
70 | values = values.stringify_keys |
General Comments 0
You need to be logged in to leave comments.
Login now