mirror of
https://github.com/opf/openproject.git
synced 2026-06-14 19:50:04 +00:00
Avoid mutator sort on relations
https://github.com/rails/rails/pull/13314 removed mutator methods (e.g., `Array#sort!`) from relations. This commit enforces either an ordering on the query itself where applicable, or uses a non-mutator sort.
This commit is contained in:
committed by
Alex Coles
parent
3ab2f80a20
commit
6eeea9d1da
@@ -388,6 +388,7 @@ class ApplicationController < ActionController::Base
|
||||
def find_work_packages
|
||||
@work_packages = WorkPackage.includes(:project)
|
||||
.where(id: params[:work_package_id] || params[:ids])
|
||||
.order('id ASC')
|
||||
fail ActiveRecord::RecordNotFound if @work_packages.empty?
|
||||
@projects = @work_packages.map(&:project).compact.uniq
|
||||
@project = @projects.first if @projects.size == 1
|
||||
@@ -551,7 +552,7 @@ class ApplicationController < ActionController::Base
|
||||
|
||||
def render_feed(items, options = {})
|
||||
@items = items || []
|
||||
@items.sort! do |x, y| y.event_datetime <=> x.event_datetime end
|
||||
@items = @items.sort do |x, y| y.event_datetime <=> x.event_datetime end
|
||||
@items = @items.slice(0, Setting.feeds_limit.to_i)
|
||||
@title = options[:title] || Setting.app_title
|
||||
render template: 'common/feed', layout: false, content_type: 'application/atom+xml'
|
||||
|
||||
@@ -39,7 +39,6 @@ class WorkPackages::BulkController < ApplicationController
|
||||
include IssuesHelper
|
||||
|
||||
def edit
|
||||
@work_packages.sort!
|
||||
@available_statuses = @projects.map { |p| Workflow.available_statuses(p) }.inject { |memo, w| memo & w }
|
||||
@custom_fields = @projects.map(&:all_work_package_custom_fields).inject { |memo, c| memo & c }
|
||||
@assignables = @projects.map(&:possible_assignees).inject { |memo, a| memo & a }
|
||||
@@ -48,8 +47,6 @@ class WorkPackages::BulkController < ApplicationController
|
||||
end
|
||||
|
||||
def update
|
||||
@work_packages.sort!
|
||||
|
||||
unsaved_work_package_ids = []
|
||||
|
||||
@work_packages.each do |work_package|
|
||||
|
||||
@@ -157,7 +157,7 @@ describe TimelogController, type: :controller do
|
||||
refute_nil TimeEntry.find_by(id: 1)
|
||||
|
||||
# remove the simulation
|
||||
TimeEntry._destroy_callbacks.reject! { |callback| callback.filter == :stop_callback_chain }
|
||||
TimeEntry._destroy_callbacks.reject { |callback| callback.filter == :stop_callback_chain }
|
||||
end
|
||||
|
||||
it 'should index all projects' do
|
||||
|
||||
Reference in New Issue
Block a user