]> source.dussan.org Git - redmine.git/commitdiff
Makes Version REST API accept due_date attribute (#10013).
authorJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 21 Jan 2012 09:39:29 +0000 (09:39 +0000)
committerJean-Philippe Lang <jp_lang@yahoo.fr>
Sat, 21 Jan 2012 09:39:29 +0000 (09:39 +0000)
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/trunk@8686 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/models/version.rb
test/integration/api_test/versions_test.rb

index 8002ac9c8d8d5643347e7e66b48319a72fb7de6c..08463976bbc4089fdb6e45fd3ab68cca6f9fafe8 100644 (file)
@@ -56,6 +56,10 @@ class Version < ActiveRecord::Base
     effective_date
   end
 
+  def due_date=(arg)
+    self.effective_date=(arg)
+  end
+
   # Returns the total estimated time for this version
   # (sum of leaves estimated_hours)
   def estimated_hours
index e250dcd50a830a34f439c41727e5ff81dbcb4295..3ad5ebf402693b7801daac1fab85de9677a67a89 100644 (file)
@@ -69,6 +69,20 @@ class ApiTest::VersionsTest < ActionController::IntegrationTest
         assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
       end
 
+      should "create the version with due date" do
+        assert_difference 'Version.count' do
+          post '/projects/1/versions.xml', {:version => {:name => 'API test', :due_date => '2012-01-24'}}, credentials('jsmith')
+        end
+
+        version = Version.first(:order => 'id DESC')
+        assert_equal 'API test', version.name
+        assert_equal Date.parse('2012-01-24'), version.due_date
+
+        assert_response :created
+        assert_equal 'application/xml', @response.content_type
+        assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
+      end
+
       context "with failure" do
         should "return the errors" do
           assert_no_difference('Version.count') do