diff --git a/app/controllers/my_profile/tasks_controller.rb b/app/controllers/my_profile/tasks_controller.rb index 9cd2b19..9599108 100644 --- a/app/controllers/my_profile/tasks_controller.rb +++ b/app/controllers/my_profile/tasks_controller.rb @@ -178,7 +178,7 @@ class TasksController < MyProfileController end def filter_tasks(filter, tasks) - tasks = tasks.includes(:requestor, :closed_by) + tasks = tasks.eager_load(:requestor, :closed_by) tasks = tasks.of(filter[:type].presence) tasks = tasks.where(:status => filter[:status]) unless filter[:status].blank? tasks = filter_by_creation_date(filter, tasks) diff --git a/app/models/task.rb b/app/models/task.rb index 2492dd1..8f9c6a6 100644 --- a/app/models/task.rb +++ b/app/models/task.rb @@ -316,7 +316,7 @@ class Task < ActiveRecord::Base scope :canceled, -> { where status: Task::Status::CANCELLED } scope :closed, -> { where status: [Task::Status::CANCELLED, Task::Status::FINISHED] } scope :opened, -> { where status: [Task::Status::ACTIVE, Task::Status::HIDDEN] } - scope :of, -> type { where "type LIKE ?", type if type } + scope :of, -> type { where "tasks.type LIKE ?", type if type } scope :order_by, -> attribute, ord { order "#{attribute} #{ord}" } scope :like, -> field, value { where "LOWER(#{field}) LIKE ?", "%#{value.downcase}%" if value } scope :pending_all, -> profile, filter_type, filter_text { diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index d8d5b25..3b72a5b 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -74,7 +74,7 @@ class TasksControllerTest < ActionController::TestCase assert_response :success assert_template 'processed' - assert_kind_of Array, assigns(:tasks) + assert_kind_of ActiveRecord::Relation, assigns(:tasks) end should 'display task created_at' do -- libgit2 0.21.2