Skip to content

Commit 0433b43

Browse files
committed
Add test for when there is no unread feedback
1 parent 580b76f commit 0433b43

File tree

1 file changed

+29
-1
lines changed

1 file changed

+29
-1
lines changed

spec/features/lesson/listing_lessons_spec.rb

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@
259259
expect(data.size).to eq(0)
260260
end
261261

262-
it 'includes has_unread_feedback when the user is a student' do
262+
it 'includes has_unread_feedback as true when there is unread feedback' do
263263
authenticated_in_hydra_as(student)
264264
create(:class_student, school_class:, student_id: student.id)
265265

@@ -295,6 +295,34 @@
295295
expect(data.first[:has_unread_feedback]).to be(true)
296296
end
297297

298+
it 'includes has_unread_feedback as false when there is no unread feedback' do
299+
authenticated_in_hydra_as(student)
300+
create(:class_student, school_class:, student_id: student.id)
301+
302+
student_project = create(
303+
:project,
304+
school:,
305+
lesson:,
306+
parent: lesson.project,
307+
remixed_from_id: lesson.project.id,
308+
user_id: student.id
309+
)
310+
school_project = student_project.school_project
311+
312+
create(
313+
:feedback,
314+
school_project: school_project,
315+
user_id: teacher.id,
316+
content: 'Unread',
317+
read_at: Time.current
318+
)
319+
320+
get('/api/lessons', headers:)
321+
data = JSON.parse(response.body, symbolize_names: true)
322+
323+
expect(data.first[:has_unread_feedback]).to be(false)
324+
end
325+
298326
it 'includes status when the user is a student' do
299327
authenticated_in_hydra_as(student)
300328
create(:class_student, school_class:, student_id: student.id)

0 commit comments

Comments
 (0)