2023-01-02 03:26:52 -08:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
require "rails_helper"
|
|
|
|
|
|
|
|
describe UseCase::MuteRule::Create do
|
|
|
|
subject { UseCase::MuteRule::Create.call(user:, phrase:) }
|
|
|
|
|
|
|
|
context "user passed" do
|
|
|
|
let(:user) { FactoryBot.create(:user) }
|
|
|
|
|
|
|
|
context "phrase is empty" do
|
|
|
|
let(:phrase) { "" }
|
|
|
|
|
2023-10-14 21:55:13 -07:00
|
|
|
it "raises an error" do
|
|
|
|
expect { subject }.to raise_error(ActiveRecord::RecordInvalid)
|
2023-01-02 03:26:52 -08:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
context "phrase is non-empty" do
|
|
|
|
let(:phrase) { "test" }
|
|
|
|
|
|
|
|
it "creates the rule" do
|
|
|
|
expect { subject }.to change { MuteRule.count }.by(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|