Add tests for mute rules

This commit is contained in:
Andreas Nedbal 2022-11-18 21:50:28 +01:00 committed by Andreas Nedbal
parent 9a96010530
commit 5f2b044d80
1 changed files with 32 additions and 0 deletions

View File

@ -17,4 +17,36 @@ describe Settings::MutesController, type: :controller do
end end
end end
end end
describe "#create" do
subject { post :create, params: { muted_phrase: "foo" } }
context "user signed in" do
let(:user) { FactoryBot.create(:user) }
before { sign_in user }
it "creates a mute rule" do
expect { subject }.to(change { MuteRule.count }.by(1))
end
end
end
describe "#destroy" do
subject { delete :destroy, params: }
context "user signed in" do
let(:user) { FactoryBot.create(:user) }
let(:rule) { MuteRule.create(user:, muted_phrase: "foo") }
let(:params) { { id: rule.id } }
before { sign_in user }
it "destroys a mute rule" do
subject
expect(MuteRule.exists?(rule.id)).to eq(false)
end
end
end
end end