Add block checks into User#answer

This commit is contained in:
Karina Kwiatek 2022-06-11 23:14:01 +02:00 committed by Karina Kwiatek
parent e9fa3b83b2
commit 65309edd8f

View file

@ -106,6 +106,9 @@ class User < ApplicationRecord
# @param question [Question] the question to answer # @param question [Question] the question to answer
# @param content [String] the answer content # @param content [String] the answer content
def answer(question, content) def answer(question, content)
raise Errors::AnsweringOtherBlockedSelf if question.user.blocking?(self)
raise Errors::AnsweringSelfBlockedOther if self.blocking?(question.user)
Answer.create!(content: content, Answer.create!(content: content,
user: self, user: self,
question: question) question: question)