Merge pull request #908 from Retrospring/fix/no-nil-on-service-missing

Handle missing services in share worker
This commit is contained in:
Karina Kwiatek 2023-01-03 12:15:27 +00:00 committed by GitHub
commit a13d3fe273
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 1 deletions

View File

@ -9,7 +9,7 @@ class ShareWorker
# @param answer_id [Integer] the user id
# @param service [String] the service to post to
def perform(user_id, answer_id, service) # rubocop:disable Metrics/AbcSize
@user_service = User.find(user_id).services.find_by(type: "Services::#{service.camelize}")
@user_service = User.find(user_id).services.find_by!(type: "Services::#{service.camelize}")
@user_service.post(Answer.find(answer_id))
rescue ActiveRecord::RecordNotFound