##// END OF EJS Templates
Include enabled modules in projects API (#17602)....
Jean-Baptiste Barth -
r13009:63cb3680c14b
parent child
Show More
@@ -91,4 +91,25 module ProjectsHelper
91 sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing)
91 sharing = 'none' unless Version::VERSION_SHARINGS.include?(sharing)
92 l("label_version_sharing_#{sharing}")
92 l("label_version_sharing_#{sharing}")
93 end
93 end
94
95 def render_api_includes(project, api)
96 api.array :trackers do
97 project.trackers.each do |tracker|
98 api.tracker(:id => tracker.id, :name => tracker.name)
99 end
100 end if include_in_api_response?('trackers')
101
102 api.array :issue_categories do
103 project.issue_categories.each do |category|
104 api.issue_category(:id => category.id, :name => category.name)
105 end
106 end if include_in_api_response?('issue_categories')
107
108 api.array :enabled_modules do
109 project.enabled_modules.each do |enabled_module|
110 api.enabled_module(:id => enabled_module.id, :name => enabled_module.name)
111 end
112 end if include_in_api_response?('enabled_modules')
113
114 end
94 end
115 end
@@ -10,6 +10,7 api.array :projects, api_meta(:total_count => @project_count, :offset => @offset
10 api.is_public project.is_public?
10 api.is_public project.is_public?
11
11
12 render_api_custom_values project.visible_custom_field_values, api
12 render_api_custom_values project.visible_custom_field_values, api
13 render_api_includes(project, api)
13
14
14 api.created_on project.created_on
15 api.created_on project.created_on
15 api.updated_on project.updated_on
16 api.updated_on project.updated_on
@@ -9,19 +9,8 api.project do
9 api.is_public @project.is_public?
9 api.is_public @project.is_public?
10
10
11 render_api_custom_values @project.visible_custom_field_values, api
11 render_api_custom_values @project.visible_custom_field_values, api
12 render_api_includes(@project, api)
12
13
13 api.created_on @project.created_on
14 api.created_on @project.created_on
14 api.updated_on @project.updated_on
15 api.updated_on @project.updated_on
15
16 api.array :trackers do
17 @project.trackers.each do |tracker|
18 api.tracker(:id => tracker.id, :name => tracker.name)
19 end
20 end if include_in_api_response?('trackers')
21
22 api.array :issue_categories do
23 @project.issue_categories.each do |category|
24 api.issue_category(:id => category.id, :name => category.name)
25 end
26 end if include_in_api_response?('issue_categories')
27 end
16 end
@@ -66,6 +66,53 class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
66 assert json['projects'].first.has_key?('id')
66 assert json['projects'].first.has_key?('id')
67 end
67 end
68
68
69 test "GET /projects.xml with include=issue_categories should return categories" do
70 get '/projects.xml?include=issue_categories'
71 assert_response :success
72 assert_equal 'application/xml', @response.content_type
73
74 assert_tag 'issue_categories',
75 :attributes => {:type => 'array'},
76 :child => {
77 :tag => 'issue_category',
78 :attributes => {
79 :id => '2',
80 :name => 'Recipes'
81 }
82 }
83 end
84
85 test "GET /projects.xml with include=trackers should return trackers" do
86 get '/projects.xml?include=trackers'
87 assert_response :success
88 assert_equal 'application/xml', @response.content_type
89
90 assert_tag 'trackers',
91 :attributes => {:type => 'array'},
92 :child => {
93 :tag => 'tracker',
94 :attributes => {
95 :id => '2',
96 :name => 'Feature request'
97 }
98 }
99 end
100
101 test "GET /projects.xml with include=enabled_modules should return enabled modules" do
102 get '/projects.xml?include=enabled_modules'
103 assert_response :success
104 assert_equal 'application/xml', @response.content_type
105
106 assert_tag 'enabled_modules',
107 :attributes => {:type => 'array'},
108 :child => {
109 :tag => 'enabled_module',
110 :attributes => {
111 :name => 'issue_tracking'
112 }
113 }
114 end
115
69 test "GET /projects/:id.xml should return the project" do
116 test "GET /projects/:id.xml should return the project" do
70 get '/projects/1.xml'
117 get '/projects/1.xml'
71 assert_response :success
118 assert_response :success
@@ -132,6 +179,21 class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
132 }
179 }
133 end
180 end
134
181
182 test "GET /projects/:id.xml with include=enabled_modules should return enabled modules" do
183 get '/projects/1.xml?include=enabled_modules'
184 assert_response :success
185 assert_equal 'application/xml', @response.content_type
186
187 assert_tag 'enabled_modules',
188 :attributes => {:type => 'array'},
189 :child => {
190 :tag => 'enabled_module',
191 :attributes => {
192 :name => 'issue_tracking'
193 }
194 }
195 end
196
135 test "POST /projects.xml with valid parameters should create the project" do
197 test "POST /projects.xml with valid parameters should create the project" do
136 Setting.default_projects_modules = ['issue_tracking', 'repository']
198 Setting.default_projects_modules = ['issue_tracking', 'repository']
137
199
General Comments 0
You need to be logged in to leave comments. Login now