]> source.dussan.org Git - redmine.git/commitdiff
Merged r19581 from trunk to 4.1-stable (#33113).
authorGo MAEDA <maeda@farend.jp>
Thu, 19 Mar 2020 08:55:46 +0000 (08:55 +0000)
committerGo MAEDA <maeda@farend.jp>
Thu, 19 Mar 2020 08:55:46 +0000 (08:55 +0000)
git-svn-id: http://svn.redmine.org/redmine/branches/4.1-stable@19584 e93f8b46-1217-0410-a6f0-8f06a7374b81

app/views/projects/show.api.rsb
test/integration/api_test/projects_test.rb

index 240b1888325e3a1ed94837e4d705a3241677068c..7ad4ecc302fc1d0bbc59c327489fd33f4d555ada 100644 (file)
@@ -8,6 +8,8 @@ api.project do
   api.status      @project.status
   api.is_public   @project.is_public?
   api.inherit_members @project.inherit_members?
+  api.default_version(:id => @project.default_version.id, :name => @project.default_version.name) if @project.default_version
+  api.default_assignee(:id => @project.project.default_assigned_to.id, :name => @project.project.default_assigned_to.name) if @project.default_assigned_to
 
   render_api_custom_values @project.visible_custom_field_values, api
   render_api_includes(@project, api)
index 6c7496fc40a83755f2b5b0c05b4829635eaddb05..b90c055bf6f588f627ec6a40cfffceb8afbb6d3d 100644 (file)
@@ -108,6 +108,8 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
     assert_kind_of Hash, json['project']
     assert_equal 1, json['project']['id']
     assert_equal false, json['project']['inherit_members']
+    assert_equal false, json['project'].has_key?('default_version')
+    assert_equal false, json['project'].has_key?('default_assignee')
   end
 
   test "GET /projects/:id.xml with hidden custom fields should not display hidden custom fields" do
@@ -152,6 +154,29 @@ class Redmine::ApiTest::ProjectsTest < Redmine::ApiTest::Base
     assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
   end
 
+  def test_get_project_with_default_version_and_assignee
+    user = User.find(3)
+    version = Version.find(1)
+    Project.find(1).update!(default_assigned_to_id: user.id, default_version_id: version.id)
+
+    get '/projects/1.json'
+
+    json = ActiveSupport::JSON.decode(response.body)
+    assert_kind_of Hash, json
+    assert_kind_of Hash, json['project']
+    assert_equal 1, json['project']['id']
+
+    assert json['project'].has_key?('default_assignee')
+    assert_equal 2, json['project']['default_assignee'].length
+    assert_equal user.id, json['project']['default_assignee']['id']
+    assert_equal user.name, json['project']['default_assignee']['name']
+
+    assert json['project'].has_key?('default_version')
+    assert_equal 2, json['project']['default_version'].length
+    assert_equal version.id, json['project']['default_version']['id']
+    assert_equal version.name, json['project']['default_version']['name']
+  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