docbrown/spec/services/users/delete_comments_spec.rb
Alex 393ba00221
Remove Elasticsearch ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ ✂️ (#13606)
* Attempt number 1

* Fix rack_attack specs

* Fix users_searches_users spec

* Fix display_users_search_spec

* Fix comment typo

* Remove search:destroy task from cypress

* Remove port 9300 from gitpod

* Stub response in attack_spec
2021-05-03 11:09:45 -04:00

33 lines
1 KiB
Ruby

require "rails_helper"
RSpec.describe Users::DeleteComments, type: :service do
let(:user) { create(:user) }
let(:trusted_user) { create(:user, :trusted) }
let(:article) { create(:article) }
let(:comment) { create(:comment, user: user, commentable: article) }
before do
create_list(:comment, 2, commentable: article, user: user)
allow(EdgeCache::BustComment).to receive(:call)
allow(EdgeCache::BustUser).to receive(:call)
end
it "destroys user comments" do
comment
described_class.call(user)
expect(Comment.where(user_id: user.id).any?).to be false
end
it "busts cache" do
described_class.call(user)
expect(EdgeCache::BustComment).to have_received(:call).with(article).at_least(:once)
expect(EdgeCache::BustUser).to have_received(:call).with(user)
end
it "destroys moderation notifications properly" do
create(:notification, notifiable: comment, action: "Moderation", user: trusted_user)
described_class.call(user)
expect(Notification.count).to eq 0
end
end