/**
  * @depends testSaveChecklistItemForTaskUsingAjax
  */
 public function testUpdateStatusViaAjax()
 {
     $super = $this->logoutCurrentUserLoginNewUserAndGetByUsername('super');
     $tasks = Task::getByName('aTest');
     $task = $tasks[0];
     $taskId = $task->id;
     $checkListItems = $task->checkListItems;
     $this->setGetArray(array('id' => $checkListItems[0]->id, 'taskId' => $taskId, 'checkListItemCompleted' => '1'));
     $content = $this->runControllerWithNoExceptionsAndGetContent('tasks/taskCheckItems/updateStatusViaAjax', true);
     $taskCheckListItem = TaskCheckListItem::getById(intval($checkListItems[0]->id));
     $this->assertTrue((bool) $taskCheckListItem->completed);
     $this->setGetArray(array('id' => $checkListItems[0]->id, 'taskId' => $taskId, 'checkListItemCompleted' => '0'));
     $content = $this->runControllerWithNoExceptionsAndGetContent('tasks/taskCheckItems/updateStatusViaAjax', true);
     $taskCheckListItem = TaskCheckListItem::getById(intval($checkListItems[0]->id));
     $this->assertFalse((bool) $taskCheckListItem->completed);
 }
 /**
  * Delete checklist item
  */
 public function actionDeleteCheckListItem($id, $taskId)
 {
     $task = Task::getById((int) $taskId);
     $taskCheckListItem = TaskCheckListItem::getById(intval($id));
     $task->checkListItems->remove($taskCheckListItem);
     $saved = $task->save();
     if (!$saved) {
         throw new FailedToSaveModelException();
     }
     $getParams = array('uniquePageId' => null, 'relatedModelId' => $task->id, 'relatedModelClassName' => 'Task', 'relatedModelRelationName' => 'checkListItems');
     $url = Yii::app()->createUrl('tasks/taskCheckItems/ajaxCheckItemListForRelatedTaskModel', $getParams);
     $this->redirect($url);
 }