From 53d99492d555a3ee9580dc0ca49a057539b01cb8 Mon Sep 17 00:00:00 2001 From: Michel Felipe Date: Mon, 2 Feb 2015 09:18:24 -0300 Subject: [PATCH] Added functional test for filter tasks by type and data name --- test/functional/tasks_controller_test.rb | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+), 0 deletions(-) diff --git a/test/functional/tasks_controller_test.rb b/test/functional/tasks_controller_test.rb index 63dd36a..bff4dff 100644 --- a/test/functional/tasks_controller_test.rb +++ b/test/functional/tasks_controller_test.rb @@ -419,6 +419,28 @@ class TasksControllerTest < ActionController::TestCase assert_includes assigns(:tasks), t3 end + should 'filter tasks by type and data content' do + class CleanHouse < Task; end + class FeedDog < Task; end + Task.stubs(:per_page).returns(3) + requestor = fast_create(Person) + t1 = CleanHouse.create!(:requestor => requestor, :target => profile, :data => {:name => 'Task Test'}) + t2 = CleanHouse.create!(:requestor => requestor, :target => profile) + t3 = FeedDog.create!(:requestor => requestor, :target => profile) + + post :index, :filter_type => t1.type, :filter_text => 'test' + + assert_includes assigns(:tasks), t1 + assert_not_includes assigns(:tasks), t2 + assert_not_includes assigns(:tasks), t3 + + post :index + + assert_includes assigns(:tasks), t1 + assert_includes assigns(:tasks), t2 + assert_includes assigns(:tasks), t3 + end + should 'return tasks ordered accordingly and limited by pages' do time = Time.now person = fast_create(Person) -- libgit2 0.21.2