Sub Folder creation via REST API #1255
This commit is contained in:
parent
facc4e25a6
commit
2a16856b1b
@ -468,7 +468,7 @@ class DmsfFolder < ActiveRecord::Base
|
||||
# Attributes
|
||||
self.title = params[:dmsf_folder][:title].strip
|
||||
self.description = params[:dmsf_folder][:description].strip
|
||||
self.dmsf_folder_id = params[:parent_id]
|
||||
self.dmsf_folder_id = params[:dmsf_folder][:dmsf_folder_id]
|
||||
# Custom fields
|
||||
if params[:dmsf_folder][:custom_field_values].present?
|
||||
i = 0
|
||||
|
||||
@ -116,6 +116,25 @@ class DmsfFolderApiTest < RedmineDmsf::Test::IntegrationTest
|
||||
assert_select 'dmsf_folder > title', text: 'rest_api'
|
||||
end
|
||||
|
||||
def test_create_subfolder
|
||||
# curl -v -H "Content-Type: application/xml" -X POST --data "@folder.xml" -u ${1}:${2} http://localhost:3000/projects/12/dmsf/create.xml
|
||||
payload = %{<?xml version="1.0" encoding="utf-8" ?>
|
||||
<dmsf_folder>
|
||||
<title>rest_api</title>
|
||||
<description>A folder created via REST API</description>
|
||||
<dmsf_folder_id>#{@folder1.id}</dmsf_folder_id>
|
||||
</dmsf_folder>}
|
||||
post "/projects/#{@project1.identifier}/dmsf/create.xml?key=#{@token.value}", params: payload, headers: { 'CONTENT_TYPE' => 'application/xml' }
|
||||
assert_response :success
|
||||
# <?xml version="1.0" encoding="UTF-8"?>
|
||||
# <dmsf_folder>
|
||||
# <id>8</id>
|
||||
# <title>rest_api</title>
|
||||
# </dmsf_folder>
|
||||
assert_select 'dmsf_folder > title', text: 'rest_api'
|
||||
assert @folder1.dmsf_folders.where(title: 'rest_api').exists?
|
||||
end
|
||||
|
||||
def test_find_folder_by_title
|
||||
# curl -v -H "Content-Type: application/json" -X GET -H "X-Redmine-API-Key: USERS_API_KEY" http://localhost:3000/projects/1/dmsf.json?folder_title=Updated%20title
|
||||
get "/projects/#{@project1.identifier}/dmsf.xml?key=#{@token.value}&folder_title=#{@folder1.title}"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user