Project

General

Profile

Feature #24976 » 24976.patch

Yuichi HARADA, 2021-04-05 09:40

View differences:

app/controllers/issues_controller.rb
112 112
        render :template => 'issues/show'
113 113
      end
114 114
      format.api do
115
        @allowed_statuses = @issue.new_statuses_allowed_to(User.current)
115 116
        @changesets = @issue.changesets.visible.preload(:repository, :user).to_a
116 117
        @changesets.reverse! if User.current.wants_comments_in_reverse_order?
117 118
      end
app/views/issues/show.api.rsb
77 77
      api.user :id => user.id, :name => user.name
78 78
    end
79 79
  end if include_in_api_response?('watchers') && User.current.allowed_to?(:view_issue_watchers, @issue.project)
80

  
81
  api.array :allowed_statuses do
82
    @allowed_statuses.each do |status|
83
      api.status :id => status.id, :name => status.name
84
    end
85
  end if include_in_api_response?('allowed_statuses')
80 86
end
test/integration/api_test/issues_test.rb
394 394
    end
395 395
  end
396 396

  
397
  test "GET /issues/:id.xml?include=allowed_statuses should include available statuses" do
398
    issue = Issue.find(1)
399
    assert_equal 1, issue.tracker_id  # Bug
400
    issue.update(:status_id => 2)     # Assigned
401
    member = Member.find_or_new(issue.project, User.find_by_login('dlopper'))
402
    assert_equal [2], member.role_ids # Developer
403

  
404
    get '/issues/1.xml?include=allowed_statuses', :headers => credentials('dlopper', 'foo')
405
    assert_response :ok
406
    assert_equal 'application/xml', response.media_type
407

  
408
    allowed_statuses = [[1, 'New'], [2, 'Assigned'], [4, 'Feedback'], [5, 'Closed'], [6, 'Rejected']]
409
    assert_select 'issue allowed_statuses[type=array]' do
410
      assert_select 'status', allowed_statuses.length
411
      assert_select('status').each_with_index do |status, idx|
412
        id, name, = allowed_statuses[idx]
413
        assert_equal id.to_s, status['id']
414
        assert_equal name, status['name']
415
      end
416
    end
417
  end
418

  
397 419
  test "GET /issues/:id.xml should contains total_estimated_hours and total_spent_hours" do
398 420
    parent = Issue.find(3)
399 421
    parent.update_columns :estimated_hours => 2.0
(2-2/2)