Fix further obsolete finders

pull/6827/head
Alex Coles 9 years ago
parent 8923de2ff8
commit 4edf3e30bc
  1. 6
      app/helpers/rb_common_helper.rb
  2. 5
      app/models/story.rb
  3. 4
      spec/models/issue_position_spec.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

@ -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

@ -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

Loading…
Cancel
Save