mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-13 09:20:38 -07:00
working on adding time to schedule
This commit is contained in:
parent
284fc73f78
commit
061a3b9fde
8 changed files with 56 additions and 9 deletions
|
|
@ -42,15 +42,30 @@ describe "survey:attempt_questions" do
|
|||
question_list: question_list,
|
||||
frequency_hours: 24 * 7,
|
||||
start_date: Time.new,
|
||||
end_date: 1.year.from_now
|
||||
end_date: 1.year.from_now,
|
||||
time: 1200
|
||||
)
|
||||
end
|
||||
|
||||
describe 'First Attempt' do
|
||||
describe 'First attempt not at specified time' do
|
||||
before :each do
|
||||
now = DateTime.now
|
||||
date = ActiveSupport::TimeZone["America/New_York"].parse(now.strftime("%Y-%m-%dT19:00:00%z"))
|
||||
Timecop.freeze(date) { subject.invoke }
|
||||
end
|
||||
|
||||
it 'should not create any attempts' do
|
||||
expect(Attempt.count).to eq(0)
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
describe 'First attempt at specified time' do
|
||||
|
||||
before :each do
|
||||
Timecop.freeze
|
||||
subject.invoke
|
||||
now = DateTime.now
|
||||
date = ActiveSupport::TimeZone["America/New_York"].parse(now.strftime("%Y-%m-%dT20:00:00%z"))
|
||||
Timecop.freeze(date) { subject.invoke }
|
||||
end
|
||||
|
||||
it 'should create the first attempt for each recipient' do
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ RSpec.describe RecipientSchedule, type: :model 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
|
||||
|
|
@ -96,7 +96,7 @@ RSpec.describe RecipientSchedule, type: :model do
|
|||
end
|
||||
|
||||
it 'should update next_attempt_at' do
|
||||
expect(recipient_schedule.next_attempt_at.to_i).to eq((Time.new + (60 * 60 * schedule.frequency_hours)).to_i)
|
||||
expect(recipient_schedule.next_attempt_at.to_i).to eq(Date.today.to_time.to_i + (960 * 60))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue