mirror of
https://github.com/edcommonwealth/sqm-dashboards.git
synced 2026-03-07 21:48:16 -08:00
don't survey on weekends
This commit is contained in:
parent
aee434a148
commit
7dc603b7ee
2 changed files with 23 additions and 4 deletions
|
|
@ -1,10 +1,12 @@
|
|||
namespace :survey do
|
||||
|
||||
desc 'Text all Recipients ready for an Attempt'
|
||||
desc 'Text all Recipients ready for an Attempt (only on weekdays)'
|
||||
task :attempt_questions => :environment do
|
||||
Schedule.active.each do |schedule|
|
||||
schedule.recipient_schedules.ready.each do |recipient_schedule|
|
||||
recipient_schedule.attempt_question
|
||||
if Date.today.on_weekday?
|
||||
Schedule.active.each do |schedule|
|
||||
schedule.recipient_schedules.ready.each do |recipient_schedule|
|
||||
recipient_schedule.attempt_question
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -13,11 +13,26 @@ describe "survey:attempt_questions" do
|
|||
let(:active_schedule) { double("active schedule", recipient_schedules: recipient_schedules) }
|
||||
|
||||
it "finds all active schedules" do
|
||||
now = DateTime.now
|
||||
now += 1.day until now.on_weekday?
|
||||
date = ActiveSupport::TimeZone["UTC"].parse(now.strftime("%Y-%m-%dT20:00:00%z"))
|
||||
Timecop.freeze(date)
|
||||
|
||||
expect(ready_recipient_schedule).to receive(:attempt_question)
|
||||
expect(active_schedule).to receive(:recipient_schedules)
|
||||
expect(Schedule).to receive(:active).and_return([active_schedule])
|
||||
subject.invoke
|
||||
end
|
||||
|
||||
it "works only on weekdays" do
|
||||
now = DateTime.now
|
||||
now += 1.day until now.on_weekend?
|
||||
date = ActiveSupport::TimeZone["UTC"].parse(now.strftime("%Y-%m-%dT20:00:00%z"))
|
||||
Timecop.freeze(date)
|
||||
|
||||
expect(ready_recipient_schedule).to_not receive(:attempt_question)
|
||||
subject.invoke
|
||||
end
|
||||
end
|
||||
|
||||
describe "complex flow" do
|
||||
|
|
@ -64,6 +79,7 @@ describe "survey:attempt_questions" do
|
|||
|
||||
before :each do
|
||||
now = DateTime.now
|
||||
now += 1.day until now.on_weekday?
|
||||
date = ActiveSupport::TimeZone["UTC"].parse(now.strftime("%Y-%m-%dT20:00:00%z"))
|
||||
Timecop.freeze(date) { subject.invoke }
|
||||
end
|
||||
|
|
@ -126,6 +142,7 @@ describe "survey:attempt_questions" do
|
|||
recipients[1].update_attributes(opted_out: true)
|
||||
|
||||
now = DateTime.now
|
||||
now += 1.day until now.on_weekday?
|
||||
date = ActiveSupport::TimeZone["UTC"].parse(now.strftime("%Y-%m-%dT20:00:00%z"))
|
||||
Timecop.freeze(date) { subject.invoke }
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue