Index: app/helpers/projects_helper.rb =================================================================== --- app/helpers/projects_helper.rb (revisiĆ³n: 14901) +++ app/helpers/projects_helper.rb (copia de trabajo) @@ -119,5 +119,18 @@ 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 + end + end + end if include_in_api_response?('documents') + end end Index: test/integration/api_test/projects_test.rb =================================================================== --- test/integration/api_test/projects_test.rb (revisiĆ³n: 14901) +++ test/integration/api_test/projects_test.rb (copia de trabajo) @@ -20,7 +20,7 @@ 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 @@ -73,6 +73,19 @@ 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 @@ -130,6 +143,19 @@ 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