Commit b47cc3509d722f2a1c7da3d31f7abbaf7df04cbc

Authored by Victor Costa
1 parent 71129f10

Fix processed tasks action in task controller

app/controllers/my_profile/tasks_controller.rb
@@ -178,7 +178,7 @@ class TasksController < MyProfileController @@ -178,7 +178,7 @@ class TasksController < MyProfileController
178 end 178 end
179 179
180 def filter_tasks(filter, tasks) 180 def filter_tasks(filter, tasks)
181 - tasks = tasks.includes(:requestor, :closed_by) 181 + tasks = tasks.eager_load(:requestor, :closed_by)
182 tasks = tasks.of(filter[:type].presence) 182 tasks = tasks.of(filter[:type].presence)
183 tasks = tasks.where(:status => filter[:status]) unless filter[:status].blank? 183 tasks = tasks.where(:status => filter[:status]) unless filter[:status].blank?
184 tasks = filter_by_creation_date(filter, tasks) 184 tasks = filter_by_creation_date(filter, tasks)
app/models/task.rb
@@ -316,7 +316,7 @@ class Task < ActiveRecord::Base @@ -316,7 +316,7 @@ class Task < ActiveRecord::Base
316 scope :canceled, -> { where status: Task::Status::CANCELLED } 316 scope :canceled, -> { where status: Task::Status::CANCELLED }
317 scope :closed, -> { where status: [Task::Status::CANCELLED, Task::Status::FINISHED] } 317 scope :closed, -> { where status: [Task::Status::CANCELLED, Task::Status::FINISHED] }
318 scope :opened, -> { where status: [Task::Status::ACTIVE, Task::Status::HIDDEN] } 318 scope :opened, -> { where status: [Task::Status::ACTIVE, Task::Status::HIDDEN] }
319 - scope :of, -> type { where "type LIKE ?", type if type } 319 + scope :of, -> type { where "tasks.type LIKE ?", type if type }
320 scope :order_by, -> attribute, ord { order "#{attribute} #{ord}" } 320 scope :order_by, -> attribute, ord { order "#{attribute} #{ord}" }
321 scope :like, -> field, value { where "LOWER(#{field}) LIKE ?", "%#{value.downcase}%" if value } 321 scope :like, -> field, value { where "LOWER(#{field}) LIKE ?", "%#{value.downcase}%" if value }
322 scope :pending_all, -> profile, filter_type, filter_text { 322 scope :pending_all, -> profile, filter_type, filter_text {
test/functional/tasks_controller_test.rb
@@ -74,7 +74,7 @@ class TasksControllerTest < ActionController::TestCase @@ -74,7 +74,7 @@ class TasksControllerTest < ActionController::TestCase
74 74
75 assert_response :success 75 assert_response :success
76 assert_template 'processed' 76 assert_template 'processed'
77 - assert_kind_of Array, assigns(:tasks) 77 + assert_kind_of ActiveRecord::Relation, assigns(:tasks)
78 end 78 end
79 79
80 should 'display task created_at' do 80 should 'display task created_at' do