From d1bb9ea917733d47874c5505ab415dbf1cb8cf9d Mon Sep 17 00:00:00 2001 From: Ruslan Kabalin Date: Thu, 5 Feb 2015 15:29:43 +0000 Subject: [PATCH] MDL-48841 admin: Fix scheduled task reset to defaults finctionality. It is safe to make fields as non-required, because form validation will not pass through any empty field anyway. --- .../task/classes/edit_scheduled_task_form.php | 5 -- .../task/tests/behat/manage_tasks.feature | 53 +++++++++++++++++++ 2 files changed, 53 insertions(+), 5 deletions(-) create mode 100644 admin/tool/task/tests/behat/manage_tasks.feature diff --git a/admin/tool/task/classes/edit_scheduled_task_form.php b/admin/tool/task/classes/edit_scheduled_task_form.php index 21d251875bb..145b59dc9ba 100644 --- a/admin/tool/task/classes/edit_scheduled_task_form.php +++ b/admin/tool/task/classes/edit_scheduled_task_form.php @@ -58,27 +58,22 @@ class tool_task_edit_scheduled_task_form extends moodleform { $mform->addElement('text', 'minute', get_string('taskscheduleminute', 'tool_task')); $mform->setType('minute', PARAM_RAW); $mform->addHelpButton('minute', 'taskscheduleminute', 'tool_task'); - $mform->addRule('minute', get_string('required'), 'required'); $mform->addElement('text', 'hour', get_string('taskschedulehour', 'tool_task')); $mform->setType('hour', PARAM_RAW); $mform->addHelpButton('hour', 'taskschedulehour', 'tool_task'); - $mform->addRule('hour', get_string('required'), 'required'); $mform->addElement('text', 'day', get_string('taskscheduleday', 'tool_task')); $mform->setType('day', PARAM_RAW); $mform->addHelpButton('day', 'taskscheduleday', 'tool_task'); - $mform->addRule('day', get_string('required'), 'required'); $mform->addElement('text', 'month', get_string('taskschedulemonth', 'tool_task')); $mform->setType('month', PARAM_RAW); $mform->addHelpButton('month', 'taskschedulemonth', 'tool_task'); - $mform->addRule('month', get_string('required'), 'required'); $mform->addElement('text', 'dayofweek', get_string('taskscheduledayofweek', 'tool_task')); $mform->setType('dayofweek', PARAM_RAW); $mform->addHelpButton('dayofweek', 'taskscheduledayofweek', 'tool_task'); - $mform->addRule('dayofweek', get_string('required'), 'required'); $mform->addElement('advcheckbox', 'disabled', get_string('disabled', 'tool_task')); $mform->addHelpButton('disabled', 'disabled', 'tool_task'); diff --git a/admin/tool/task/tests/behat/manage_tasks.feature b/admin/tool/task/tests/behat/manage_tasks.feature new file mode 100644 index 00000000000..2a511012268 --- /dev/null +++ b/admin/tool/task/tests/behat/manage_tasks.feature @@ -0,0 +1,53 @@ +@tool @tool_task @javascript +Feature: Manage scheduled tasks + In order to configure scheduled tasks + As an admin + I need to be able to disable, enable, edit and reset to default scheduled tasks + + Background: + Given I log in as "admin" + And I navigate to "Scheduled tasks" node in "Site administration > Server" + + Scenario: Disable scheduled task + When I click on "Edit task schedule: Log table cleanup" "link" in the "Log table cleanup" "table_row" + Then I should see "Edit task schedule: Log table cleanup" + And I set the following fields to these values: + | disabled | 1 | + And I press "Save changes" + Then I should see "Changes saved" + And I should see "Task disabled" in the "Log table cleanup" "table_row" + + Scenario: Enable scheduled task + When I click on "Edit task schedule: Log table cleanup" "link" in the "Log table cleanup" "table_row" + Then I should see "Edit task schedule: Log table cleanup" + And I set the following fields to these values: + | disabled | 0 | + And I press "Save changes" + Then I should see "Changes saved" + And I should not see "Task disabled" in the "Log table cleanup" "table_row" + + Scenario: Edit scheduled task + When I click on "Edit task schedule: Log table cleanup" "link" in the "Log table cleanup" "table_row" + Then I should see "Edit task schedule: Log table cleanup" + And I set the following fields to these values: + | minute | */5 | + | hour | 1 | + | day | 2 | + | month | 3 | + | dayofweek | 4 | + And I press "Save changes" + Then I should see "Changes saved" + And the following should exist in the "admintable" table: + | Component | Minute | Hour | Day | Day of week | Month | + | Standard log | */5 | 1 | 2 | 4 | 3 | + + Scenario: Reset scheduled task to default + When I click on "Edit task schedule: Log table cleanup" "link" in the "Log table cleanup" "table_row" + Then I should see "Edit task schedule: Log table cleanup" + And I set the following fields to these values: + | resettodefaults | 1 | + And I press "Save changes" + Then I should see "Changes saved" + And the following should not exist in the "admintable" table: + | Component | Minute | Hour | Day | Day of week | Month | + | Standard log | */5 | 1 | 2 | 4 | 3 | \ No newline at end of file