From 4edf3e30bcd230cb43c1b037621135649fa3a86b Mon Sep 17 00:00:00 2001 From: Alex Coles Date: Sat, 29 Aug 2015 11:40:26 +0200 Subject: [PATCH] Fix further obsolete finders --- app/helpers/rb_common_helper.rb | 6 +++--- app/models/story.rb | 5 +++-- spec/models/issue_position_spec.rb | 4 ++-- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/app/helpers/rb_common_helper.rb b/app/helpers/rb_common_helper.rb index 998a7a74a3..f1f4f46107 100644 --- a/app/helpers/rb_common_helper.rb +++ b/app/helpers/rb_common_helper.rb @@ -211,9 +211,9 @@ module RbCommonHelper end def all_workflows - @all_workflows ||= Workflow.all(include: [:new_status, :old_status], - conditions: { role_id: User.current.roles_for_project(@project).map(&:id), - type_id: story_types.map(&:id) }) + @all_workflows ||= Workflow.includes([:new_status, :old_status]) + .where(role_id: User.current.roles_for_project(@project).map(&:id), + type_id: story_types.map(&:id)) end def all_work_package_status diff --git a/app/models/story.rb b/app/models/story.rb index 58f0fef20f..465ef97e38 100644 --- a/app/models/story.rb +++ b/app/models/story.rb @@ -166,8 +166,9 @@ class Story < WorkPackage extras = ["and not #{WorkPackage.table_name}.position is NULL and #{WorkPackage.table_name}.position <= ?", position] end - @rank ||= WorkPackage.count(conditions: Story.condition(project.id, fixed_version_id, extras), joins: :status) - + @rank ||= WorkPackage.where(Story.condition(project.id, fixed_version_id, extras)) + .joins(:status) + .count @rank end diff --git a/spec/models/issue_position_spec.rb b/spec/models/issue_position_spec.rb index 4f073fd835..a79654fc19 100644 --- a/spec/models/issue_position_spec.rb +++ b/spec/models/issue_position_spec.rb @@ -136,8 +136,8 @@ describe WorkPackage, type: :model do work_package_2.fixed_version = sprint_2 work_package_2.save! - expect(sprint_1.fixed_issues.all(order: 'id')).to eq([work_package_1, work_package_3, work_package_4, work_package_5]) - expect(sprint_1.fixed_issues.all(order: 'id').each(&:reload).map(&:position)).to eq([1, 2, 3, 4]) + expect(sprint_1.fixed_issues.order('id')).to eq([work_package_1, work_package_3, work_package_4, work_package_5]) + expect(sprint_1.fixed_issues.order('id').each(&:reload).map(&:position)).to eq([1, 2, 3, 4]) end end