From eb2638a25fa8ff416e60bacc3e1a85ddaba525a4 Mon Sep 17 00:00:00 2001 From: Jean-Philippe Lang Date: Sat, 4 Feb 2012 11:17:30 +0000 Subject: [PATCH] Backported r8686 from trunk (#10013). git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/1.3-stable@8770 e93f8b46-1217-0410-a6f0-8f06a7374b81 --- app/models/version.rb | 4 ++++ test/integration/api_test/versions_test.rb | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/app/models/version.rb b/app/models/version.rb index 3340be77e..2681ef23d 100644 --- a/app/models/version.rb +++ b/app/models/version.rb @@ -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 diff --git a/test/integration/api_test/versions_test.rb b/test/integration/api_test/versions_test.rb index f325d2c25..420e9411e 100644 --- a/test/integration/api_test/versions_test.rb +++ b/test/integration/api_test/versions_test.rb @@ -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'}}, :authorization => 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