]> source.dussan.org Git - redmine.git/commitdiff
Fixed that custom_fields property is ignored for time entries in REST API (#11112).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 9 Jun 2012 07:55:26 +0000 (07:55 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 9 Jun 2012 07:55:26 +0000 (07:55 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@9783 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/time_entry.rb
test/integration/api_test/time_entries_test.rb

index 9008965affcf778cfac06a39aa102513b3c04d44..ef085d875626b04681828220a89f6a5269e05259 100644 (file)
@@ -66,7 +66,7 @@ class TimeEntry < ActiveRecord::Base
     end
   }
 
-  safe_attributes 'hours', 'comments', 'issue_id', 'activity_id', 'spent_on', 'custom_field_values'
+  safe_attributes 'hours', 'comments', 'issue_id', 'activity_id', 'spent_on', 'custom_field_values', 'custom_fields'
 
   def initialize(attributes=nil, *args)
     super
index 7a220678cae60be463c6ee5e28bae753a1b4a9ce..b18013496d715fc0b7ba8f9a74e360df5454d6ed 100644 (file)
@@ -79,6 +79,21 @@ class ApiTest::TimeEntriesTest < ActionController::IntegrationTest
         assert_equal 3.5, entry.hours
         assert_equal TimeEntryActivity.find(11), entry.activity
       end
+
+      should "accept custom fields" do
+        field = TimeEntryCustomField.create!(:name => 'Test', :field_format => 'string')
+
+        assert_difference 'TimeEntry.count' do
+          post '/time_entries.xml', {:time_entry => {
+            :issue_id => '1', :spent_on => '2010-12-02', :hours => '3.5', :activity_id => '11', :custom_fields => [{:id => field.id.to_s, :value => 'accepted'}]
+          }}, credentials('jsmith')
+        end
+        assert_response :created
+        assert_equal 'application/xml', @response.content_type
+
+        entry = TimeEntry.first(:order => 'id DESC')
+        assert_equal 'accepted', entry.custom_field_value(field)
+      end
     end
 
     context "with project_id" do