Chatwoot/spec/jobs/conversations/reopen_snoozed_conversations_job_spec.rb
Sojan Jose d955d8e7dc
feat: Ability to snooze conversations (#2682)
Co-authored-by: Pranav Raj S <pranav@chatwoot.com>
2021-07-23 15:24:07 +05:30

22 lines
881 B
Ruby

require 'rails_helper'
RSpec.describe Conversations::ReopenSnoozedConversationsJob, type: :job do
let!(:snoozed_till_5_minutes_ago) { create(:conversation, status: :snoozed, snoozed_until: 5.minutes.ago) }
let!(:snoozed_till_tomorrow) { create(:conversation, status: :snoozed, snoozed_until: 1.day.from_now) }
let!(:snoozed_indefinitely) { create(:conversation, status: :snoozed) }
it 'enqueues the job' do
expect { described_class.perform_later }.to have_enqueued_job(described_class)
.on_queue('low')
end
context 'when called' do
it 'reopens snoozed conversations whose snooze until has passed' do
described_class.perform_now
expect(snoozed_till_5_minutes_ago.reload.status).to eq 'open'
expect(snoozed_till_tomorrow.reload.status).to eq 'snoozed'
expect(snoozed_indefinitely.reload.status).to eq 'snoozed'
end
end
end