docbrown/spec/services/notifications
Daniel Uber 293ff5653a
Fix integer > nil error when sending reaction notifications (#16627)
* don't set nil when size not called

recently, #16570 worked around an issue where aggregated siblings
wasn't present, by only calling size if present.

Unfortunately, this causes a comparison of integer (new json_data
aggregated siblings count) with nil (result of the safe navigation for dig()&.size
assigned nil to previous_siblings_size, when we expected it to be
0). The initial error on the same data moved farther down the controller.

If old_json_data is present, but does not have an array in
reaction.aggregated_siblings, we want to have previous size be zero.

Remove guard clause and previous assignment

The issue was not that old_json_data was nil (it came from an existing
notification) but that there were missing keys (or rather that the
json data for some notifications didn't have a reaction key at all).

Remove the guard clause and either set to the size, or zero if there
is none. I don't understand what the guard clause was for, so replace the
safety by adding a nil safe call to dig. I don't _believe_ this is
possible but in case it was we can shorten the check here.

* Add test to cover missing json_data['reaction'] key

* Remove unneeded temporary variable
2022-02-17 16:30:39 -06:00
..
milestone Bump rubocop from 1.15.0 to 1.16.0 (#13894) 2021-06-02 09:11:38 -04:00
moderation Rename User.dev_account to User.staff_account (#14321) 2021-07-26 10:46:26 -04:00
new_badge_achievement Configure badge credits by admins (#13145) 2021-03-30 10:58:48 +03:00
new_comment Add spec to ensure we filter by proper user IDs for sending push notifications (#14187) 2021-07-12 08:51:00 -05:00
new_follower Ensure arguments to perform_async are json safe (#16285) 2022-01-25 18:07:40 -06:00
new_mention app/models i18n (#16124) 2022-02-03 13:41:42 -05:00
notifiable_action Don't notify authors about own org posts (#15113) 2021-10-19 21:32:44 +07:00
reactions Fix integer > nil error when sending reaction notifications (#16627) 2022-02-17 16:30:39 -06:00
tag_adjustment_notification [deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
welcome_notification Abstract DatadogStatsClient to ForemStatsClient (#12304) 2021-01-27 11:25:44 -05:00
remove_all_by_action_spec.rb [deploy] Rubocop: fix violations of Layout/LineLength (#9197) 2020-07-08 08:36:36 -05:00
remove_all_spec.rb Rubocop: enable and fix new Rails cops (#9537) 2020-07-29 11:14:19 +02:00
update_spec.rb Flaky Spec Fix:Remove let_it_be Test Prof Helper (#9556) 2020-07-29 11:31:01 +02:00