Question: user association is optional

This commit is contained in:
Georg Gadinger 2020-04-30 18:39:33 +02:00
parent 07f489430c
commit dd5f718f31
2 changed files with 2 additions and 2 deletions

View File

@ -1,7 +1,7 @@
class Question < ApplicationRecord
include Question::AnswerMethods
belongs_to :user
belongs_to :user, optional: true
has_many :answers, dependent: :destroy
has_many :inboxes, dependent: :destroy

View File

@ -186,7 +186,7 @@ describe Ajax::AnswerController, type: :controller do
describe "#destroy" do
let(:answer_user) { user }
let(:question) { FactoryBot.create(:question, user: FactoryBot.create(:user)) }
let(:question) { FactoryBot.create(:question) }
let(:answer) { FactoryBot.create(:answer, user: answer_user, question: question) }
let(:answer_id) { answer.id }