Spec Fix:Nullify Rating Votes when Deleting Users (#10071)

This commit is contained in:
Molly Struve 2020-08-29 09:00:33 -05:00 committed by GitHub
parent 83c2e1427c
commit 12dfe4ab3b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -115,6 +115,10 @@ RSpec.describe Users::Delete, type: :service do
create_associations(direct_associations.select { |a| kept_association_names.include?(a.name) })
end
before do
allow(user).to receive(:trusted).and_return(true)
end
def create_associations(names)
associations = []
@ -146,6 +150,11 @@ RSpec.describe Users::Delete, type: :service do
end
it "keeps the kept associations" do
# Rating Vote must be for NOT the user's own article
other_article = create(:article)
rating_vote = kept_associations.detect { |a| a.is_a?(RatingVote) }
rating_vote.update(article_id: other_article.id)
expect(kept_associations).not_to be_empty
user.reload
described_class.call(user)