diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 09:08:11 +0000 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2020-03-25 09:08:11 +0000 |
commit | 5064bf8c5647d4c4430cbb4d097cf1592416de29 (patch) | |
tree | d051bf2abe2cc7061b3a7facb6669a56ccb9cf54 /lib/api | |
parent | 9c83aadd2604e7e6cb1f84683f951e6b12872618 (diff) | |
download | gitlab-ce-5064bf8c5647d4c4430cbb4d097cf1592416de29.tar.gz |
Add latest changes from gitlab-org/gitlab@master
Diffstat (limited to 'lib/api')
-rw-r--r-- | lib/api/discussions.rb | 11 | ||||
-rw-r--r-- | lib/api/environments.rb | 3 |
2 files changed, 7 insertions, 7 deletions
diff --git a/lib/api/discussions.rb b/lib/api/discussions.rb index a1cec148aeb..8ff275a3a1b 100644 --- a/lib/api/discussions.rb +++ b/lib/api/discussions.rb @@ -28,10 +28,10 @@ module API get ":id/#{noteables_path}/:noteable_id/discussions" do noteable = find_noteable(noteable_type, params[:noteable_id]) - notes = readable_discussion_notes(noteable) - discussions = Kaminari.paginate_array(Discussion.build_collection(notes, noteable)) + discussion_ids = paginate(noteable.discussion_ids_relation) + notes = readable_discussion_notes(noteable, discussion_ids) - present paginate(discussions), with: Entities::Discussion + present Discussion.build_collection(notes, noteable), with: Entities::Discussion end desc "Get a single #{noteable_type.to_s.downcase} discussion" do @@ -221,10 +221,9 @@ module API helpers do # rubocop: disable CodeReuse/ActiveRecord - def readable_discussion_notes(noteable, discussion_id = nil) + def readable_discussion_notes(noteable, discussion_ids) notes = noteable.notes - notes = notes.where(discussion_id: discussion_id) if discussion_id - notes = notes + .where(discussion_id: discussion_ids) .inc_relations_for_view .includes(:noteable) .fresh diff --git a/lib/api/environments.rb b/lib/api/environments.rb index ec58b3b7bb9..e5db9cdedc8 100644 --- a/lib/api/environments.rb +++ b/lib/api/environments.rb @@ -82,9 +82,10 @@ module API requires :environment_id, type: Integer, desc: 'The environment ID' end delete ':id/environments/:environment_id' do - authorize! :update_environment, user_project + authorize! :read_environment, user_project environment = user_project.environments.find(params[:environment_id]) + authorize! :destroy_environment, environment destroy_conditionally!(environment) end |