Feature #36848 ยป issues_index_api.patch
| app/views/issues/index.api.rsb | ||
|---|---|---|
| 32 | 32 | 
    end  | 
| 33 | 33 | 
          end if include_in_api_response?('attachments')
   | 
| 34 | 34 | |
| 35 | 
    api.array :watchers do  | 
|
| 36 | 
    issue.watcher_users.each do |user|  | 
|
| 37 | 
    api.user :id => user.id, :name => user.name  | 
|
| 38 | 
    end  | 
|
| 39 | 
          end if include_in_api_response?('watchers') && User.current.allowed_to?(:view_issue_watchers, issue.project)
   | 
|
| 40 | ||
| 35 | 41 | 
    api.array :relations do  | 
| 36 | 42 | 
    issue.relations.each do |relation|  | 
| 37 | 43 | 
    api.relation(:id => relation.id, :issue_id => relation.issue_from_id, :issue_to_id => relation.issue_to_id, :relation_type => relation.relation_type, :delay => relation.delay)  | 
| test/functional/issues_controller_test.rb | ||
|---|---|---|
| 8274 | 8274 | 
    end  | 
| 8275 | 8275 | 
    end  | 
| 8276 | 8276 | 
    end  | 
| 8277 | ||
| 8278 | 
    def test_should_not_list_the_wathcers_in_issue_index_api_without_permission  | 
|
| 8279 | 
        get :index, params: { :include => ["watchers"], :format => 'json' }
   | 
|
| 8280 | 
    assert_response :success  | 
|
| 8281 | 
    assert_not_include 'watchers', response.body  | 
|
| 8282 | 
    end  | 
|
| 8283 | ||
| 8284 | 
    def test_should_list_the_wathcers_in_issue_index_api_with_permission  | 
|
| 8285 | 
    Role.last.add_permission!(:view_issue_watchers)  | 
|
| 8286 | 
        get :index, params: { :include => ["watchers"], :format => 'json' }
   | 
|
| 8287 | 
    assert_response :success  | 
|
| 8288 | 
    watchers = Watcher.where(watchable_type: 'Issue').sort_by(&:user_id)  | 
|
| 8289 | ||
| 8290 | 
    if watchers.count  | 
|
| 8291 | 
    watchers.each do |watcher|  | 
|
| 8292 | 
            st = "{\"id\":#{watcher.user.id},\"name\":\"#{watcher.user.name}\"}"
   | 
|
| 8293 | 
    assert_include st, response.body  | 
|
| 8294 | 
    end  | 
|
| 8295 | 
    end  | 
|
| 8296 | 
    end  | 
|
| 8277 | 8297 | 
    end  |