From dd5f718f31f26948e400be43abfef66ffd049bd5 Mon Sep 17 00:00:00 2001 From: Georg Gadinger Date: Thu, 30 Apr 2020 18:39:33 +0200 Subject: [PATCH] Question: user association is optional --- app/models/question.rb | 2 +- spec/controllers/ajax/answer_controller_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/question.rb b/app/models/question.rb index 65daf030..78ea192d 100644 --- a/app/models/question.rb +++ b/app/models/question.rb @@ -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 diff --git a/spec/controllers/ajax/answer_controller_spec.rb b/spec/controllers/ajax/answer_controller_spec.rb index 55aa7ad6..d80c5b82 100644 --- a/spec/controllers/ajax/answer_controller_spec.rb +++ b/spec/controllers/ajax/answer_controller_spec.rb @@ -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 }