Spec Fix:Nullify Rating Votes when Deleting Users (#10071)
This commit is contained in:
parent
83c2e1427c
commit
12dfe4ab3b
1 changed files with 9 additions and 0 deletions
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue