Project

General

Profile

Patch #21378 » include_documents_in_projects_api_v1.patch

Helder Manuel Torres Vieira, 2015-11-29 21:31

View differences:

app/helpers/projects_helper.rb (copia de trabajo)
end
end if include_in_api_response?('enabled_modules')
api.array :documents do
project.documents.each do |document|
api.document do
api.id document.id
api.title document.title
api.description document.description
api.category(:id => document.category.id, :name => document.category.name)
api.url url_for(:controller => 'documents', :action => 'show', :id => document, :only_path => false)
api.created_on document.created_on
api.updated_on document.updated_on
end
end
end if include_in_api_response?('documents')
end
end
test/integration/api_test/projects_test.rb (copia de trabajo)
class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
fixtures :projects, :versions, :users, :roles, :members, :member_roles, :issues, :journals, :journal_details,
:trackers, :projects_trackers, :issue_statuses, :enabled_modules, :enumerations, :boards, :messages,
:attachments, :custom_fields, :custom_values, :time_entries, :issue_categories
:attachments, :custom_fields, :custom_values, :time_entries, :issue_categories, :documents
def setup
super
......
assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
end
test "GET /projects.xml with include=documents should return documents" do
get '/projects.xml?include=documents'
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_select 'documents[type=array]>document>id', :text => '1'
assert_select 'documents[type=array]>document>title', :text => 'Test document'
assert_select 'documents[type=array]>document>description', :text => 'Document description'
assert_select 'documents[type=array]>document>category[id="1"]'
assert_select 'documents[type=array]>document>category[name="Uncategorized"]'
assert_select 'documents[type=array]>document>url', :text => 'http://www.example.com/documents/1'
end
test "GET /projects/:id.xml should return the project" do
get '/projects/1.xml'
assert_response :success
......
assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
end
test "GET /projects/:id.xml with include=documents should return documents" do
get '/projects/1.xml?include=documents'
assert_response :success
assert_equal 'application/xml', @response.content_type
assert_select 'documents[type=array]>document>id', :text => '1'
assert_select 'documents[type=array]>document>title', :text => 'Test document'
assert_select 'documents[type=array]>document>description', :text => 'Document description'
assert_select 'documents[type=array]>document>category[id="1"]'
assert_select 'documents[type=array]>document>category[name="Uncategorized"]'
assert_select 'documents[type=array]>document>url', :text => 'http://www.example.com/documents/1'
end
test "POST /projects.xml with valid parameters should create the project" do
with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
assert_difference('Project.count') do
(2-2/2)