|
199 | 199 | let!(:lesson) { create(:lesson, school_class:, name: 'Test Lesson', visibility: 'students', user_id: teacher.id) } |
200 | 200 | let(:teacher) { create(:teacher, school:) } |
201 | 201 |
|
202 | | - let(:class_student) do |
| 202 | + let!(:class_student) do |
203 | 203 | create(:class_student, school_class:, student_id: student.id) |
204 | 204 | end |
205 | 205 |
|
|
229 | 229 |
|
230 | 230 | it "includes the lesson when the user is a school-student within the lesson's class" do |
231 | 231 | authenticated_in_hydra_as(student) |
232 | | - create(:class_student, school_class:, student_id: student.id) |
233 | | - |
234 | 232 | get('/api/lessons', headers:) |
235 | 233 | data = JSON.parse(response.body, symbolize_names: true) |
236 | 234 |
|
|
239 | 237 |
|
240 | 238 | it 'does not include the submitted_count when the user is a school-student within the lesson\'s class' do |
241 | 239 | authenticated_in_hydra_as(student) |
242 | | - create(:class_student, school_class:, student_id: student.id) |
243 | | - |
244 | 240 | get('/api/lessons', headers:) |
245 | 241 | data = JSON.parse(response.body, symbolize_names: true) |
246 | 242 | expect(data.first).not_to have_key(:submitted_count) |
247 | 243 | end |
248 | 244 |
|
249 | 245 | it "includes the remix identifier when the user has remixed the lesson's project" do |
250 | | - student = create(:student, school:) |
251 | 246 | authenticated_in_hydra_as(student) |
252 | | - create(:class_student, school_class:, student_id: student.id) |
253 | 247 | student_project = create(:project, school:, lesson:, parent: lesson.project, remixed_from_id: lesson.project.id, user_id: student.id) |
254 | 248 |
|
255 | 249 | get('/api/lessons', headers:) |
|
258 | 252 | end |
259 | 253 |
|
260 | 254 | it "does not include the lesson when the user is not a school-student within the lesson's class" do |
261 | | - authenticated_in_hydra_as(student) |
| 255 | + another_student = create(:student, school:) |
| 256 | + authenticated_in_hydra_as(another_student) |
262 | 257 |
|
263 | 258 | get('/api/lessons', headers:) |
264 | 259 | data = JSON.parse(response.body, symbolize_names: true) |
|
278 | 273 |
|
279 | 274 | it 'includes has_unread_feedback as true when there is unread feedback' do |
280 | 275 | authenticated_in_hydra_as(student) |
281 | | - create(:class_student, school_class:, student_id: student.id) |
282 | | - |
283 | 276 | create( |
284 | 277 | :feedback, |
285 | 278 | school_project: school_project, |
|
304 | 297 |
|
305 | 298 | it 'includes has_unread_feedback as false when there is no unread feedback' do |
306 | 299 | authenticated_in_hydra_as(student) |
307 | | - create(:class_student, school_class:, student_id: student.id) |
308 | | - |
309 | 300 | create( |
310 | 301 | :feedback, |
311 | 302 | school_project: school_project, |
|
322 | 313 |
|
323 | 314 | it 'includes status when the user is a student' do |
324 | 315 | authenticated_in_hydra_as(student) |
325 | | - create(:class_student, school_class:, student_id: student.id) |
326 | | - |
327 | 316 | school_project.transition_status_to!(:submitted, teacher.id) |
328 | 317 |
|
329 | 318 | get('/api/lessons', headers:) |
|
335 | 324 |
|
336 | 325 | it 'includes the default status when no transitions have happened' do |
337 | 326 | authenticated_in_hydra_as(student) |
338 | | - create(:class_student, school_class:, student_id: student.id) |
339 | | - |
340 | 327 | create( |
341 | 328 | :project, |
342 | 329 | school:, |
|
0 commit comments