##// END OF EJS Templates
Merged r11760 from trunk (#13850)....
Jean-Philippe Lang -
r11607:af632568e3e9
parent child
Show More
@@ -47,7 +47,8 class Version < ActiveRecord::Base
47 'wiki_page_title',
47 'wiki_page_title',
48 'status',
48 'status',
49 'sharing',
49 'sharing',
50 'custom_field_values'
50 'custom_field_values',
51 'custom_fields'
51
52
52 # Returns true if +user+ or current user is allowed to view the version
53 # Returns true if +user+ or current user is allowed to view the version
53 def visible?(user=User.current)
54 def visible?(user=User.current)
@@ -82,6 +82,29 class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
82 assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
82 assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
83 end
83 end
84
84
85 should "create the version with custom fields" do
86 field = VersionCustomField.generate!
87
88 assert_difference 'Version.count' do
89 post '/projects/1/versions.xml', {
90 :version => {
91 :name => 'API test',
92 :custom_fields => [
93 {'id' => field.id.to_s, 'value' => 'Some value'}
94 ]
95 }
96 }, credentials('jsmith')
97 end
98
99 version = Version.first(:order => 'id DESC')
100 assert_equal 'API test', version.name
101 assert_equal 'Some value', version.custom_field_value(field)
102
103 assert_response :created
104 assert_equal 'application/xml', @response.content_type
105 assert_select 'version>custom_fields>custom_field[id=?]>value', field.id.to_s, 'Some value'
106 end
107
85 context "with failure" do
108 context "with failure" do
86 should "return the errors" do
109 should "return the errors" do
87 assert_no_difference('Version.count') do
110 assert_no_difference('Version.count') do
@@ -148,4 +148,15 module ObjectHelpers
148 attachment.save!
148 attachment.save!
149 attachment
149 attachment
150 end
150 end
151
152 def CustomField.generate!(attributes={})
153 @generated_custom_field_name ||= 'Custom field 0'
154 @generated_custom_field_name.succ!
155 field = new(attributes)
156 field.name = @generated_custom_field_name.dup if field.name.blank?
157 field.field_format = 'string' if field.field_format.blank?
158 yield field if block_given?
159 field.save!
160 field
161 end
151 end
162 end
General Comments 0
You need to be logged in to leave comments. Login now