File tree Expand file tree Collapse file tree 1 file changed +33
-0
lines changed
Expand file tree Collapse file tree 1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change @@ -208,4 +208,37 @@ def test_tutor_cant_delete_other_staff_notes
208208 assert StaffNote . find_by ( id : note . id ) , 'Staff note was deleted'
209209 end
210210
211+ def test_project_staff_note_count
212+ unit = FactoryBot . create ( :unit , code : 'COS10001' )
213+
214+ student = FactoryBot . create ( :user , :student )
215+ student_project = unit . enrol_student ( student , nil )
216+
217+ tutor1 = FactoryBot . create ( :user , :tutor )
218+ unit . employ_staff ( tutor1 , Role . tutor )
219+
220+ # Create 2 staff notes
221+ StaffNote . create! ( {
222+ note : "Test note 1" ,
223+ project : student_project ,
224+ user : tutor1
225+ } )
226+
227+ StaffNote . create! ( {
228+ note : "Test note 2" ,
229+ project : student_project ,
230+ user : tutor1
231+ } )
232+
233+ add_auth_header_for ( user : tutor1 )
234+
235+ get "/api/students?withdrawn=false&unit_id=#{ unit . id } "
236+ assert_equal 200 , last_response . status
237+
238+ matching = JSON . parse ( last_response . body ) . find { |project | project [ "student" ] [ "id" ] == student . id }
239+
240+ # Ensure project returns a staff note count of 2
241+ assert_equal 2 , matching [ "staff_note_count" ]
242+ end
243+
211244end
You can’t perform that action at this time.
0 commit comments