From c131db47618e40f3e6b948e77a93da399f8b6140 Mon Sep 17 00:00:00 2001 From: Andrew Nicols Date: Wed, 19 Nov 2014 13:10:04 +0800 Subject: [PATCH] MDL-22043 mod_forum: Fix toggle subscription editing button behaviour Update the user session property before generating the button which relies upon it. --- mod/forum/subscribers.php | 2 +- .../behat/forum_subscriptions_management.feature | 46 ++++++++++++++++++++++ 2 files changed, 47 insertions(+), 1 deletion(-) create mode 100644 mod/forum/tests/behat/forum_subscriptions_management.feature diff --git a/mod/forum/subscribers.php b/mod/forum/subscribers.php index 51b6f54b891..b02ac7bb8a2 100644 --- a/mod/forum/subscribers.php +++ b/mod/forum/subscribers.php @@ -101,10 +101,10 @@ $PAGE->navbar->add($strsubscribers); $PAGE->set_title($strsubscribers); $PAGE->set_heading($COURSE->fullname); if (has_capability('mod/forum:managesubscriptions', $context)) { - $PAGE->set_button(forum_update_subscriptions_button($course->id, $id)); if ($edit != -1) { $USER->subscriptionsediting = $edit; } + $PAGE->set_button(forum_update_subscriptions_button($course->id, $id)); } else { unset($USER->subscriptionsediting); } diff --git a/mod/forum/tests/behat/forum_subscriptions_management.feature b/mod/forum/tests/behat/forum_subscriptions_management.feature new file mode 100644 index 00000000000..af651ca6a8e --- /dev/null +++ b/mod/forum/tests/behat/forum_subscriptions_management.feature @@ -0,0 +1,46 @@ +@mod @mod_forum +Feature: A teacher can control the subscription to a forum + In order to change individual user's subscriptions + As a course administrator + I can change subscription setting for my users + + Background: + Given the following "users" exist: + | username | firstname | lastname | email | + | teacher | Teacher | Tom | teacher@example.com | + | student1 | Student | 1 | student.1@example.com | + | student2 | Student | 2 | student.2@example.com | + And the following "courses" exist: + | fullname | shortname | category | + | Course 1 | C1 | 0 | + And the following "course enrolments" exist: + | user | course | role | + | teacher | C1 | editingteacher | + | student1 | C1 | student | + | student2 | C1 | student | + And I log in as "teacher" + And I follow "Course 1" + And I turn editing mode on + And I add a "Forum" to section "1" and I fill the form with: + | Forum name | Test forum name | + | Forum type | Standard forum for general use | + | Description | Test forum description | + | Subscription mode | Auto subscription | + + Scenario: A teacher can change toggle subscription editing on and off + Given I follow "Test forum name" + And I follow "Show/edit current subscribers" + Then ".userselector" "css_element" should not exist + And "Turn editing on" "button" should exist + And I press "Turn editing on" + And ".userselector" "css_element" should exist + And "Turn editing off" "button" should exist + And I press "Turn editing off" + And ".userselector" "css_element" should not exist + And "Turn editing on" "button" should exist + And I press "Turn editing on" + And ".userselector" "css_element" should exist + And "Turn editing off" "button" should exist + And I press "Turn editing off" + And ".userselector" "css_element" should not exist + And "Turn editing on" "button" should exist -- 2.11.4.GIT