Skip to content

[Rails5] Fix `can't modify frozen Array` errors

blackst0ne requested to merge blackst0ne-rails5-fix-frozen-array into master

What does this MR do?

Fixes

RuntimeError:
  can't modify frozen Array

errors for rails5 specs.

Example:

 300) cycle analytics events GET /:namespace/:project/cycle_analytics/events/issues lists the issue events
       Failure/Error: users.compact!
       
       RuntimeError:
         can't modify frozen Array
       # ./app/services/notification_recipient_service.rb:58:in `compact!'
       # ./app/services/notification_recipient_service.rb:58:in `add_recipients'
       # ./app/services/notification_recipient_service.rb:124:in `add_project_watchers'
       # ./app/services/notification_recipient_service.rb:217:in `build!'
       # ./app/services/notification_recipient_service.rb:80:in `notification_recipients'
       # ./app/services/notification_recipient_service.rb:14:in `build_recipients'
       # ./app/services/notification_service.rb:379:in `new_resource_email'
       # ./app/services/notification_service.rb:113:in `new_merge_request'
       # ./app/workers/new_merge_request_worker.rb:9:in `perform'
       # Skipped...

Are there points in the code the reviewer needs to double check?

No.

Why was this MR needed?

Migration to Rails 5.0.

Screenshots (if relevant)

No.

Does this MR meet the acceptance criteria?

What are the relevant issue numbers?

#14286 (closed) and !12841 (closed)

Edited by blackst0ne

Merge request reports