0001-Show-default-asignee-and-default-version-in-projects.patch

Marius BALTEANU, 2020-03-14 17:25

Download (3.15 KB)

View differences:

app/views/projects/show.api.rsb
8 8
  api.status      @project.status
9 9
  api.is_public   @project.is_public?
10 10
  api.inherit_members @project.inherit_members?
11
  api.default_version(:id => @project.default_version.id, :name => @project.default_version.name) if @project.default_version
12
  api.default_assignee(:id => @project.project.default_assigned_to.id, :name => @project.project.default_assigned_to.name) if @project.default_assigned_to
11 13

  
12 14
  render_api_custom_values @project.visible_custom_field_values, api
13 15
  render_api_includes(@project, api)
test/integration/api_test/projects_test.rb
108 108
    assert_kind_of Hash, json['project']
109 109
    assert_equal 1, json['project']['id']
110 110
    assert_equal false, json['project']['inherit_members']
111
    assert_equal false, json['project'].has_key?('default_version')
112
    assert_equal false, json['project'].has_key?('default_assignee')
111 113
  end
112 114

  
113 115
  test "GET /projects/:id.xml with hidden custom fields should not display hidden custom fields" do
......
152 154
    assert_select 'enabled_modules[type=array] enabled_module[name=issue_tracking]'
153 155
  end
154 156

  
157
  def test_get_project_with_default_version_and_assignee
158
    user = User.find(3)
159
    version = Version.find(1)
160
    Project.find(1).update!(default_assigned_to_id: user.id, default_version_id: version.id)
161

  
162
    get '/projects/1.json'
163

  
164
    json = ActiveSupport::JSON.decode(response.body)
165
    assert_kind_of Hash, json
166
    assert_kind_of Hash, json['project']
167
    assert_equal 1, json['project']['id']
168
    puts json.inspect
169

  
170
    assert json['project'].has_key?('default_assignee')
171
    assert_equal 2, json['project']['default_assignee'].length
172
    assert_equal user.id, json['project']['default_assignee']['id']
173
    assert_equal user.name, json['project']['default_assignee']['name']
174

  
175
    assert json['project'].has_key?('default_version')
176
    assert_equal 2, json['project']['default_version'].length
177
    assert_equal version.id, json['project']['default_version']['id']
178
    assert_equal version.name, json['project']['default_version']['name']
179
  end
180

  
155 181
  test "POST /projects.xml with valid parameters should create the project" do
156 182
    with_settings :default_projects_modules => ['issue_tracking', 'repository'] do
157 183
      assert_difference('Project.count') do
158
-