Appease the dog overlords

This commit is contained in:
Andreas Nedbal 2023-01-01 21:30:41 +01:00 committed by Andreas Nedbal
parent a74f40ecfc
commit 9b5470cfd3
2 changed files with 5 additions and 1 deletions

View File

@ -8,7 +8,11 @@ class Answer < ApplicationRecord
has_many :subscriptions, dependent: :destroy
has_many :comment_smiles, through: :comments, source: :smiles
# rubocop:disable Rails/UniqueValidationWithoutIndex
# This cop is disabled here because there already are questions with
# multiple answers. Adding an index would break things database-side
validates :question_id, uniqueness: { scope: :user_id }
# rubocop:enable Rails/UniqueValidationWithoutIndex
# rubocop:disable Rails/SkipsModelValidations
after_create do

View File

@ -9,6 +9,6 @@ describe "Answer uniqueness" do
subject { 2.times { user.answer(question, "random") } }
it "does not allow answering the same question twice" do
expect{ subject }.to raise_error(ActiveRecord::RecordInvalid)
expect { subject }.to raise_error(ActiveRecord::RecordInvalid)
end
end