diff test/integration/api_test/versions_test.rb @ 1295:622f24f53b42 redmine-2.3

Update to Redmine SVN revision 11972 on 2.3-stable branch
author Chris Cannam
date Fri, 14 Jun 2013 09:02:21 +0100
parents 433d4f72a19b
children
line wrap: on
line diff
--- a/test/integration/api_test/versions_test.rb	Fri Jun 14 09:01:12 2013 +0100
+++ b/test/integration/api_test/versions_test.rb	Fri Jun 14 09:02:21 2013 +0100
@@ -1,5 +1,5 @@
 # Redmine - project management software
-# Copyright (C) 2006-2012  Jean-Philippe Lang
+# Copyright (C) 2006-2013  Jean-Philippe Lang
 #
 # This program is free software; you can redistribute it and/or
 # modify it under the terms of the GNU General Public License
@@ -17,7 +17,7 @@
 
 require File.expand_path('../../../test_helper', __FILE__)
 
-class ApiTest::VersionsTest < ActionController::IntegrationTest
+class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
   fixtures :projects, :trackers, :issue_statuses, :issues,
            :enumerations, :users, :issue_categories,
            :projects_trackers,
@@ -25,7 +25,6 @@
            :member_roles,
            :members,
            :enabled_modules,
-           :workflows,
            :versions
 
   def setup
@@ -83,6 +82,29 @@
         assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
       end
 
+      should "create the version with custom fields" do
+        field = VersionCustomField.generate!
+
+        assert_difference 'Version.count' do
+          post '/projects/1/versions.xml', {
+              :version => {
+                :name => 'API test',
+                :custom_fields => [
+                  {'id' => field.id.to_s, 'value' => 'Some value'}
+                ]
+              }
+            }, credentials('jsmith')
+        end
+
+        version = Version.first(:order => 'id DESC')
+        assert_equal 'API test', version.name
+        assert_equal 'Some value', version.custom_field_value(field)
+
+        assert_response :created
+        assert_equal 'application/xml', @response.content_type
+        assert_select 'version>custom_fields>custom_field[id=?]>value', field.id.to_s, 'Some value'
+      end
+
       context "with failure" do
         should "return the errors" do
           assert_no_difference('Version.count') do