|
|
|
|
@ -57,6 +57,20 @@ RSpec.describe RecipientSchedule, type: :model do
|
|
|
|
|
Timecop.freeze
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'with an opted out recipient' do
|
|
|
|
|
before :each do
|
|
|
|
|
recipient_schedule.recipient.update_attributes(opted_out: true)
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
let!(:attempt) { recipient_schedule.attempt_question }
|
|
|
|
|
|
|
|
|
|
it 'should not do anything' do
|
|
|
|
|
expect(attempt).to be_nil
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
describe 'with an opted in recipient' do
|
|
|
|
|
let!(:attempt) { recipient_schedule.attempt_question }
|
|
|
|
|
|
|
|
|
|
it 'should make an attempt to ask the next question' do
|
|
|
|
|
@ -85,4 +99,5 @@ RSpec.describe RecipientSchedule, type: :model do
|
|
|
|
|
expect(recipient_schedule.next_attempt_at.to_i).to eq((Time.new + (60 * 60 * schedule.frequency_hours)).to_i)
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
|