zooniverse / talk-api

Apache License 2.0
6 stars 0 forks source link

rails-5.0-message-controller-spec #331

Closed Tooyosi closed 2 months ago

Tooyosi commented 2 months ago

Issue is caused by how the exists? method called on the users association behaves in rails 4.2 and 5.

Calling r.users.exists?(id: user.id) in rails 4 returns true even before persisting the record (and the array is actually empty at this point) while on 5 it is abit stricter and evaluates as false if the associations have not been properly formed since the record at that point has not been persisted (users array eventually has data after calling the .save).

Workaround is to check if persisted before checking in the users and if not, check on the conversations users instead.

NB: participant? is originally implemented on the base ApplicationPolicy, i am overriding in the MessagePolicy class as it is also used elsewhere