1@core
2Feature: Context freezing apply to child contexts
3  In order to preserve content
4  As a manager
5  I can disbale writes at different areas
6
7  Background:
8    Given the following config values are set as admin:
9      | contextlocking | 1 |
10    And the following "users" exist:
11      | username  | firstname | lastname | email                 |
12      | teacher   | Ateacher  | Teacher  | teacher@example.com   |
13      | student1  | Astudent  | Astudent | student1@example.com  |
14    And the following "categories" exist:
15      | name  | category | idnumber |
16      | cata  | 0        | cata     |
17      | cataa | cata     | cataa    |
18      | catb  | 0        | catb     |
19    And the following "courses" exist:
20      | fullname  | shortname | category  |
21      | courseaa1 | courseaa1 | cataa     |
22      | courseaa2 | courseaa2 | cataa     |
23      | courseb   | courseb   | catb      |
24    And the following "activities" exist:
25      | activity  | name    | course    | idnumber  |
26      | forum     | faa1    | courseaa1 | faa1      |
27      | forum     | faa1b   | courseaa1 | faa1b     |
28      | forum     | faa2    | courseaa2 | faa2      |
29      | forum     | fb      | courseb   | fb        |
30    And the following "course enrolments" exist:
31      | user      | course    | role           |
32      | teacher   | courseaa1 | editingteacher |
33      | student1  | courseaa1 | student        |
34      | teacher   | courseaa2 | editingteacher |
35      | student1  | courseaa2 | student        |
36      | teacher   | courseb   | editingteacher |
37      | student1  | courseb   | student        |
38
39  Scenario: Freeze course module module should freeze just that module
40    Given I am on the "courseaa1" "Course" page logged in as "admin"
41    And I follow "faa1"
42    And "Add a new discussion topic" "link" should exist
43    When I follow "Freeze this context"
44    And I click on "Continue" "button"
45    Then "Add a new discussion topic" "link" should not exist
46    When I am on "courseaa1" course homepage
47    Then I should see "Turn editing on"
48    When I follow "faa1b"
49    Then "Add a new discussion topic" "link" should exist
50    When I am on "courseaa2" course homepage
51    Then I should see "Turn editing on"
52    When I follow "faa2"
53    Then "Add a new discussion topic" "link" should exist
54    When I am on "courseb" course homepage
55    Then I should see "Turn editing on"
56    When I follow "fb"
57    Then "Add a new discussion topic" "link" should exist
58
59    And I log out
60    When I am on the "courseaa1" "Course" page logged in as "teacher"
61    And I follow "faa1"
62    Then "Add a new discussion topic" "link" should not exist
63    When I am on "courseaa1" course homepage
64    Then I should see "Turn editing on"
65    When I follow "faa1b"
66    Then "Add a new discussion topic" "link" should exist
67    When I am on "courseaa2" course homepage
68    Then I should see "Turn editing on"
69    When I follow "faa2"
70    Then "Add a new discussion topic" "link" should exist
71    When I am on "courseb" course homepage
72    Then I should see "Turn editing on"
73    When I follow "fb"
74    And "Add a new discussion topic" "link" should exist
75
76    And I log out
77    When I am on the "courseaa1" "Course" page logged in as "student1"
78    And I follow "faa1"
79    Then "Add a new discussion topic" "link" should not exist
80    When I am on "courseaa1" course homepage
81    When I follow "faa1b"
82    Then "Add a new discussion topic" "link" should exist
83    When I am on "courseaa2" course homepage
84    When I follow "faa2"
85    Then "Add a new discussion topic" "link" should exist
86    When I am on "courseb" course homepage
87    When I follow "fb"
88    Then "Add a new discussion topic" "link" should exist
89
90  Scenario: Freeze course should freeze all children
91    Given I am on the "courseaa1" "Course" page logged in as "admin"
92    And I should see "Turn editing on"
93    When I follow "Freeze this context"
94    And I click on "Continue" "button"
95    Then I should not see "Turn editing on"
96    Then "Add a new discussion topic" "link" should not exist
97    When I am on "courseaa1" course homepage
98    Then I should not see "Turn editing on"
99    And "Unfreeze this context" "link" should exist in current page administration
100    When I follow "faa1b"
101    Then "Add a new discussion topic" "link" should not exist
102    And "Unfreeze this context" "link" should not exist in current page administration
103    When I am on "courseaa2" course homepage
104    Then I should see "Turn editing on"
105    When I follow "faa2"
106    Then "Add a new discussion topic" "link" should exist
107    When I am on "courseb" course homepage
108    Then I should see "Turn editing on"
109    When I follow "fb"
110    Then "Add a new discussion topic" "link" should exist
111
112    And I log out
113    When I am on the "courseaa1" "Course" page logged in as "teacher"
114    And I follow "faa1"
115    Then "Add a new discussion topic" "link" should not exist
116    When I am on "courseaa1" course homepage
117    Then I should not see "Turn editing on"
118    When I follow "faa1b"
119    Then "Add a new discussion topic" "link" should not exist
120    When I am on "courseaa2" course homepage
121    Then I should see "Turn editing on"
122    When I follow "faa2"
123    Then "Add a new discussion topic" "link" should exist
124    When I am on "courseb" course homepage
125    Then I should see "Turn editing on"
126    When I follow "fb"
127    Then "Add a new discussion topic" "link" should exist
128
129    And I log out
130    When I am on the "courseaa1" "Course" page logged in as "student1"
131    And I follow "faa1"
132    Then "Add a new discussion topic" "link" should not exist
133    When I am on "courseaa1" course homepage
134    When I follow "faa1b"
135    Then "Add a new discussion topic" "link" should not exist
136    When I am on "courseaa2" course homepage
137    When I follow "faa2"
138    Then "Add a new discussion topic" "link" should exist
139    When I am on "courseb" course homepage
140    When I follow "fb"
141    Then "Add a new discussion topic" "link" should exist
142
143  Scenario: Freeze course category should freeze all children
144    Given I log in as "admin"
145    And I go to the courses management page
146    And I click on "managecontextlock" action for "cata" in management category listing
147    And I click on "Continue" "button"
148    And I am on "courseaa1" course homepage
149    And I should not see "Turn editing on"
150    Then "Add a new discussion topic" "link" should not exist
151    When I am on "courseaa1" course homepage
152    Then I should not see "Turn editing on"
153    And "Unfreeze this context" "link" should not exist in current page administration
154    When I follow "faa1b"
155    Then "Add a new discussion topic" "link" should not exist
156    And "Unfreeze this context" "link" should not exist in current page administration
157    When I am on "courseaa2" course homepage
158    Then I should not see "Turn editing on"
159    When I follow "faa2"
160    Then "Add a new discussion topic" "link" should not exist
161    And "Unfreeze this context" "link" should not exist in current page administration
162    When I am on "courseb" course homepage
163    Then I should see "Turn editing on"
164    When I follow "fb"
165    Then "Add a new discussion topic" "link" should exist
166
167    And I log out
168    When I am on the "courseaa1" "Course" page logged in as "teacher"
169    Then I should not see "Turn editing on"
170    And I follow "faa1"
171    Then "Add a new discussion topic" "link" should not exist
172    When I am on "courseaa1" course homepage
173    Then I should not see "Turn editing on"
174    When I follow "faa1b"
175    Then "Add a new discussion topic" "link" should not exist
176    When I am on "courseaa2" course homepage
177    Then I should not see "Turn editing on"
178    When I follow "faa2"
179    Then "Add a new discussion topic" "link" should not exist
180    When I am on "courseb" course homepage
181    Then I should see "Turn editing on"
182    When I follow "fb"
183    Then "Add a new discussion topic" "link" should exist
184
185    And I log out
186    When I am on the "courseaa1" "Course" page logged in as "student1"
187    And I follow "faa1"
188    Then "Add a new discussion topic" "link" should not exist
189    When I am on "courseaa1" course homepage
190    When I follow "faa1b"
191    Then "Add a new discussion topic" "link" should not exist
192    When I am on "courseaa2" course homepage
193    When I follow "faa2"
194    Then "Add a new discussion topic" "link" should not exist
195    When I am on "courseb" course homepage
196    When I follow "fb"
197    Then "Add a new discussion topic" "link" should exist
198