Add spec for inbox cleanup scheduler job
This commit is contained in:
parent
a9e4265a1a
commit
d044705ca4
|
@ -0,0 +1,26 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require "rails_helper"
|
||||||
|
|
||||||
|
describe Scheduler::InboxCleanupScheduler do
|
||||||
|
let(:user) { FactoryBot.create(:user) }
|
||||||
|
let(:inbox) { FactoryBot.create(:inbox, user:) }
|
||||||
|
|
||||||
|
describe "#perform" do
|
||||||
|
before do
|
||||||
|
inbox.question_id = nil
|
||||||
|
inbox.save(validate: false)
|
||||||
|
end
|
||||||
|
|
||||||
|
subject { described_class.new.perform }
|
||||||
|
|
||||||
|
it "should delete orphaned inbox entries" do
|
||||||
|
expect { subject }
|
||||||
|
.to(
|
||||||
|
change { Inbox.where(question_id: nil).count }
|
||||||
|
.from(1)
|
||||||
|
.to(0),
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue