Commit 0072a1e3 authored by Stan Hu's avatar Stan Hu

Merge branch 'issue-link-dates' into 'master'

Expose creation/update times for issue links

See merge request gitlab-org/gitlab!48051
parents 64bf56df dcd9f6eb
......@@ -328,7 +328,9 @@ class Issue < ApplicationRecord
related_issues = ::Issue
.select(['issues.*', 'issue_links.id AS issue_link_id',
'issue_links.link_type as issue_link_type_value',
'issue_links.target_id as issue_link_source_id'])
'issue_links.target_id as issue_link_source_id',
'issue_links.created_at as issue_link_created_at',
'issue_links.updated_at as issue_link_updated_at'])
.joins("INNER JOIN issue_links ON
(issue_links.source_id = issues.id AND issue_links.target_id = #{id})
OR
......
---
title: Expose creation/update times for issue links
merge_request: 48051
author:
type: added
......@@ -57,7 +57,9 @@ Parameters:
"web_url": "http://example.com/example/example/issues/14",
"confidential": false,
"weight": null,
"link_type": "relates_to"
"link_type": "relates_to",
"link_created_at": "2016-01-07T12:44:33.959Z",
"link_updated_at": "2016-01-07T12:44:33.959Z"
}
]
```
......
......@@ -5,6 +5,8 @@ module API
class RelatedIssue < ::API::Entities::Issue
expose :issue_link_id
expose :issue_link_type, as: :link_type
expose :issue_link_created_at, as: :link_created_at
expose :issue_link_updated_at, as: :link_updated_at
end
end
end
......@@ -14,7 +14,9 @@
"link_type": {
"type": "string",
"enum": ["relates_to", "blocks", "is_blocked_by"]
}
},
"link_created_at": { "type": "date" },
"link_updated_at": { "type": "date" }
},
"required" : [ "source_issue", "target_issue", "link_type" ]
}
......@@ -369,6 +369,20 @@ RSpec.describe Issue do
expect(link_types).not_to include(nil)
end
it 'returns issues including the link creation time' do
dates = authorized_issue_a.related_issues(user).map(&:issue_link_created_at)
expect(dates).not_to be_empty
expect(dates).not_to include(nil)
end
it 'returns issues including the link update time' do
dates = authorized_issue_a.related_issues(user).map(&:issue_link_updated_at)
expect(dates).not_to be_empty
expect(dates).not_to include(nil)
end
describe 'when a user cannot read cross project' do
it 'only returns issues within the same project' do
expect(Ability).to receive(:allowed?).with(user, :read_all_resources, :global).at_least(:once).and_call_original
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment