diff options
author | Jarka Kadlecova <jarka@gitlab.com> | 2017-07-10 09:38:42 +0200 |
---|---|---|
committer | Jarka Kadlecova <jarka@gitlab.com> | 2017-07-24 08:13:43 +0200 |
commit | 7bee7b848aab883a6869e1fd2fbb9e66182d2023 (patch) | |
tree | 286029930e7c9af9402a752a1dd6f2ab9c607776 /lib/api | |
parent | 2fa22a07296223c1239bfab94654487cca222097 (diff) | |
download | gitlab-ce-7bee7b848aab883a6869e1fd2fbb9e66182d2023.tar.gz |
Support both internal and external issue trackers
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/entities.rb | 2 | ||||
-rw-r--r-- | lib/api/merge_requests.rb | 17 |
2 files changed, 9 insertions, 10 deletions
diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 09a88869063..1719e9f7205 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -109,7 +109,7 @@ module API user.avatar_url(only_path: false) end expose :star_count, :forks_count - expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? } + expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) } expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] } expose :public_builds, as: :public_jobs expose :ci_config_path diff --git a/lib/api/merge_requests.rb b/lib/api/merge_requests.rb index 6e2e13e0a24..f64ac659413 100644 --- a/lib/api/merge_requests.rb +++ b/lib/api/merge_requests.rb @@ -29,14 +29,6 @@ module API render_api_error!(errors, 400) end - def issue_entity(project) - if project.has_external_issue_tracker? - Entities::ExternalIssue - else - Entities::IssueBasic - end - end - def find_merge_requests(args = {}) args = params.merge(args) @@ -278,7 +270,14 @@ module API get ':id/merge_requests/:merge_request_iid/closes_issues' do merge_request = find_merge_request_with_access(params[:merge_request_iid]) issues = ::Kaminari.paginate_array(merge_request.closes_issues(current_user)) - present paginate(issues), with: issue_entity(user_project), current_user: current_user + issues = paginate(issues) + + external_issues, internal_issues = issues.partition { |issue| issue.is_a?(ExternalIssue) } + + data = Entities::IssueBasic.represent(internal_issues, current_user: current_user) + data += Entities::ExternalIssue.represent(external_issues, current_user: current_user) + + data.as_json end end end |