Merged r11760 from trunk (#13850).
git-svn-id: svn+ssh://rubyforge.org/var/svn/redmine/branches/2.3-stable@11837 e93f8b46-1217-0410-a6f0-8f06a7374b81
This commit is contained in:
1 parent
2c408ca6a5
commit
af632568e3
3 files changed
+36
-1
No files matched your search
@@ -47,7 +47,8 @@ class Version < ActiveRecord::Base
|
|||||||
'wiki_page_title',
|
'wiki_page_title',
|
||||||
'status',
|
'status',
|
||||||
'sharing',
|
'sharing',
|
||||||
'custom_field_values'
|
'custom_field_values',
|
||||||
|
'custom_fields'
|
||||||
|
|
||||||
# Returns true if +user+ or current user is allowed to view the version
|
# Returns true if +user+ or current user is allowed to view the version
|
||||||
def visible?(user=User.current)
|
def visible?(user=User.current)
|
||||||
|
|||||||
@@ -82,6 +82,29 @@ class Redmine::ApiTest::VersionsTest < Redmine::ApiTest::Base
|
|||||||
assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
|
assert_tag 'version', :child => {:tag => 'id', :content => version.id.to_s}
|
||||||
end
|
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
|
context "with failure" do
|
||||||
should "return the errors" do
|
should "return the errors" do
|
||||||
assert_no_difference('Version.count') do
|
assert_no_difference('Version.count') do
|
||||||
|
|||||||
@@ -148,4 +148,15 @@ module ObjectHelpers
|
|||||||
attachment.save!
|
attachment.save!
|
||||||
attachment
|
attachment
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def CustomField.generate!(attributes={})
|
||||||
|
@generated_custom_field_name ||= 'Custom field 0'
|
||||||
|
@generated_custom_field_name.succ!
|
||||||
|
field = new(attributes)
|
||||||
|
field.name = @generated_custom_field_name.dup if field.name.blank?
|
||||||
|
field.field_format = 'string' if field.field_format.blank?
|
||||||
|
yield field if block_given?
|
||||||
|
field.save!
|
||||||
|
field
|
||||||
|
end
|
||||||
end
|
end
|
||||||
Reference in new issue
Block a user