* Turn CacheBuster into a module This class used no internal state, so repeatedly creating short-lived objects seems wasteful. * Consistently use string interpolation and parenthesis * Destructure arrays into meaningful names, formatting * Fix request spec for internal classified listings controller Interestingly this works when asserting directly on the module, but not on a double. Asserting directly in the module seems sufficient for this test so the indirection was removed. * Turn CacheBuster into a module This class used no internal state, so repeatedly creating short-lived objects seems wasteful. * Fix specs after rebasing
31 lines
779 B
Ruby
31 lines
779 B
Ruby
require "rails_helper"
|
|
|
|
RSpec.describe Users::Delete, type: :service do
|
|
let(:user) { create(:user) }
|
|
|
|
it "deletes user" do
|
|
described_class.call(user)
|
|
expect(User.find_by(id: user.id)).to be_nil
|
|
end
|
|
|
|
it "busts user profile page" do
|
|
allow(CacheBuster).to receive(:bust)
|
|
described_class.new(user).call
|
|
expect(CacheBuster).to have_received(:bust).with("/#{user.username}")
|
|
end
|
|
|
|
it "deletes user's follows" do
|
|
create(:follow, follower: user)
|
|
create(:follow, followable: user)
|
|
|
|
expect do
|
|
described_class.call(user)
|
|
end.to change(Follow, :count).by(-2)
|
|
end
|
|
|
|
it "deletes user's articles" do
|
|
article = create(:article, user: user)
|
|
described_class.call(user)
|
|
expect(Article.find_by(id: article.id)).to be_nil
|
|
end
|
|
end
|