@@ -252,12 +252,49 @@ def test_create_feedback_group_chip
252252 parent_chip_id : nil ,
253253 learning_outcome_id : learning_outcome . id
254254 }
255+
256+ chip_count = learning_outcome . feedback_chips . count
257+
255258 add_auth_header_for user : User . first
256259 post_json 'api/feedback_chips' , data_to_post
257260 assert_equal 201 , last_response . status
261+
262+ assert_equal chip_count + 1 , learning_outcome . feedback_chips . count
263+
264+ response_keys = %w[ id chip_text description parent_chip_id learning_outcome_id ]
265+ data = last_response_body
266+ assert_json_matches_model Feedback ::FeedbackGroupChip . last , data , response_keys
267+ assert_equal Feedback ::FeedbackGroupChip . last . id , data [ 'id' ]
258268 end
259269
260270 def test_create_feedback_template_chip
271+ learning_outcome = FactoryBot . create ( :learning_outcome )
272+ group_chip = FactoryBot . create ( :feedback_group_chip , learning_outcome_id : learning_outcome . id )
273+ data_to_post = {
274+ type : 'template' ,
275+ chip_text : 'Sample chip text' ,
276+ description : 'Sample description' ,
277+ learning_outcome_id : learning_outcome . id ,
278+ task_status : TaskStatus . complete . name ,
279+ comment_text : 'Sample comment text' ,
280+ summary_text : 'Sample summary text'
281+ }
282+ add_auth_header_for user : User . first
283+
284+ chip_count = learning_outcome . feedback_chips . count
285+
286+ post_json 'api/feedback_chips' , data_to_post
287+ assert_equal 201 , last_response . status
288+
289+ assert_equal chip_count + 1 , learning_outcome . feedback_chips . count
290+
291+ response_keys = %w[ id chip_text description learning_outcome_id task_status comment_text summary_text ]
292+ data = last_response_body
293+ assert_json_matches_model Feedback ::FeedbackTemplateChip . last , data , response_keys
294+ assert_equal Feedback ::FeedbackTemplateChip . last . id , data [ 'id' ]
295+ end
296+
297+ def test_create_feedback_template_chip_with_parent
261298 learning_outcome = FactoryBot . create ( :learning_outcome )
262299 group_chip = FactoryBot . create ( :feedback_group_chip , learning_outcome_id : learning_outcome . id )
263300 data_to_post = {
@@ -271,8 +308,18 @@ def test_create_feedback_template_chip
271308 summary_text : 'Sample summary text'
272309 }
273310 add_auth_header_for user : User . first
311+
312+ chip_count = learning_outcome . feedback_chips . count
313+
274314 post_json 'api/feedback_chips' , data_to_post
275315 assert_equal 201 , last_response . status
316+
317+ assert_equal chip_count + 1 , learning_outcome . feedback_chips . count
318+
319+ response_keys = %w[ id chip_text description learning_outcome_id parent_chip_id task_status comment_text summary_text ]
320+ data = last_response_body
321+ assert_json_matches_model Feedback ::FeedbackTemplateChip . last , data , response_keys
322+ assert_equal Feedback ::FeedbackTemplateChip . last . id , data [ 'id' ]
276323 end
277324
278325 def test_get_all_feedback_chips_for_a_context
@@ -336,22 +383,22 @@ def test_change_chip_type_t_to_g
336383 learning_outcome = FactoryBot . create ( :learning_outcome )
337384 group_chip = FactoryBot . create ( :feedback_group_chip , learning_outcome_id : learning_outcome . id )
338385 template_chip = FactoryBot . create ( :feedback_template_chip , chip_text : 'chippy' , description : 'blah blah' , comment_text : 'your work is horrible' , summary_text : 'just plain bad' , task_status : TaskStatus . complete . name , learning_outcome_id : learning_outcome . id , parent_chip_id : group_chip . id )
339- puts template_chip . inspect
386+ # puts template_chip.inspect
340387 data_to_post = {
341388 type : 'group' ,
342389 chip_text : 'Sample chip text' ,
343390 description : 'Sample description'
344391 }
345392 add_auth_header_for user : User . first
346393 put_json "api/feedback_chips/#{ template_chip . id } " , data_to_post
347- puts last_response . body
394+ # puts last_response.body
348395 assert_equal 200 , last_response . status
349396 end
350397
351398 def test_change_chip_type_g_to_t
352399 learning_outcome = FactoryBot . create ( :learning_outcome )
353400 group_chip = FactoryBot . create ( :feedback_group_chip , learning_outcome_id : learning_outcome . id )
354- puts group_chip . inspect
401+ # puts group_chip.inspect
355402 data_to_post = {
356403 type : 'template' ,
357404 chip_text : 'Sample chip text' ,
@@ -364,7 +411,7 @@ def test_change_chip_type_g_to_t
364411 }
365412 add_auth_header_for user : User . first
366413 put_json "api/feedback_chips/#{ group_chip . id } " , data_to_post
367- puts last_response . body
414+ # puts last_response.body
368415 assert_equal 200 , last_response . status
369416 end
370417
@@ -377,7 +424,7 @@ def test_update_without_type
377424 }
378425 add_auth_header_for user : User . first
379426 put_json "api/feedback_chips/#{ group_chip . id } " , data_to_post
380- puts last_response . body
427+ # puts last_response.body
381428 assert_equal 200 , last_response . status
382429 end
383430
@@ -390,7 +437,7 @@ def test_get_global_context_chips
390437 feedback_template_chip2 = FactoryBot . create ( :feedback_template_chip , learning_outcome_id : learning_outcome2 . id , parent_chip_id : feedback_group_chip2 . id )
391438 add_auth_header_for user : User . first
392439 get 'api/global/feedback_chips'
393- puts last_response . body
440+ # puts last_response.body
394441 assert_equal 200 , last_response . status
395442 end
396443end
0 commit comments