diff --git a/spec/services/users/delete_spec.rb b/spec/services/users/delete_spec.rb index 28c69e9c3..5b5f32bb8 100644 --- a/spec/services/users/delete_spec.rb +++ b/spec/services/users/delete_spec.rb @@ -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)