mirror of
https://github.com/Retrospring/retrospring.git
synced 2025-01-18 20:15:59 +01:00
Add tests for mute rule use cases
This commit is contained in:
parent
04bc1da8cf
commit
b3a7cf388a
2 changed files with 43 additions and 0 deletions
27
spec/lib/use_case/mute_rule/create_spec.rb
Normal file
27
spec/lib/use_case/mute_rule/create_spec.rb
Normal file
|
@ -0,0 +1,27 @@
|
|||
# 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) { "" }
|
||||
|
||||
it "does not create the rule" do
|
||||
expect { subject }.not_to(change { MuteRule.count })
|
||||
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
|
16
spec/lib/use_case/mute_rule/destroy_spec.rb
Normal file
16
spec/lib/use_case/mute_rule/destroy_spec.rb
Normal file
|
@ -0,0 +1,16 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require "rails_helper"
|
||||
|
||||
describe UseCase::MuteRule::Destroy do
|
||||
subject { UseCase::MuteRule::Destroy.call(rule:) }
|
||||
|
||||
context "rule exists" do
|
||||
let(:user) { FactoryBot.create(:user) }
|
||||
let(:rule) { MuteRule.create(user:, muted_phrase: "test") }
|
||||
|
||||
it "deletes the mute rule" do
|
||||
expect { subject }.to change { MuteRule.exists?(rule.id) }.from(true).to(false)
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue