VRFS-736 refactoring
This commit is contained in:
parent
f53ca0010d
commit
70f34120b3
|
|
@ -0,0 +1,14 @@
|
|||
<% provide(:title, @title) %>
|
||||
|
||||
<p>Hello <%= EmailBatchProgression::VAR_FIRST_NAME %> --
|
||||
</p>
|
||||
|
||||
<p>We noticed that you have downloaded the free JamKazam application, but you have not yet run the app. You can find other musicians and listen to sessions and recordings on our website, but you need to run the JamKazam application to play with other musicians online. If you are having trouble installing or running the app, please visit our JamKazam support center at the link below, and post a request for assistance so that we can help you get up and running.
|
||||
</p>
|
||||
|
||||
<p>
|
||||
<a style="color: #588C98;" href="https://jamkazam.desk.com/">https://jamkazam.desk.com</a>
|
||||
</p>
|
||||
|
||||
<p>-- Team JamKazam
|
||||
</p>
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
<% provide(:title, @title) %>
|
||||
|
||||
Hello <%= EmailBatchProgression::VAR_FIRST_NAME %> --
|
||||
|
||||
We noticed that you have downloaded the free JamKazam application, but you have not yet run the app. You can find other musicians and listen to sessions and recordings on our website, but you need to run the JamKazam application to play with other musicians online. If you are having trouble installing or running the app, please visit our JamKazam support center at the link below, and post a request for assistance so that we can help you get up and running.
|
||||
|
||||
-- Team JamKazam
|
||||
|
|
@ -58,109 +58,73 @@ describe EmailBatch do
|
|||
|
||||
context 'user progress' do
|
||||
|
||||
before { pending }
|
||||
# before { pending }
|
||||
|
||||
describe 'one at a time' do
|
||||
|
||||
describe 'client not downloaded' do
|
||||
# before { pending }
|
||||
|
||||
let(:batchp) {
|
||||
FactoryGirl.create(:email_batch_progression, :sub_type => :client_notdl)
|
||||
}
|
||||
let(:user_) { FactoryGirl.create(:user) }
|
||||
let(:user_existing) {
|
||||
FactoryGirl.create(:user,
|
||||
:created_at => Time.now - (2 * batchp.days_past_for_trigger_index(2)).days)
|
||||
}
|
||||
|
||||
after(:each) do
|
||||
batchp.clear_batch_sets!
|
||||
Timecop.return
|
||||
end
|
||||
|
||||
it 'sends one email' do
|
||||
pending
|
||||
user_existing
|
||||
batchp.deliver_batch
|
||||
expect(ProgressMailer.deliveries.length).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'client not downloaded' do
|
||||
before { pending }
|
||||
|
||||
let(:batchp) {
|
||||
FactoryGirl.create(:email_batch_progression, :sub_type => :client_notdl)
|
||||
}
|
||||
|
||||
let(:user_) { FactoryGirl.create(:user) }
|
||||
|
||||
let(:user_existing) {
|
||||
FactoryGirl.create(:user,
|
||||
:created_at => Time.now - (2 * batchp.days_past_for_trigger_index(2)).days)
|
||||
}
|
||||
|
||||
after(:each) do
|
||||
batchp.clear_batch_sets!
|
||||
Timecop.return
|
||||
end
|
||||
|
||||
it 'returns no users' do
|
||||
it 'returns new user triggers' do
|
||||
user_
|
||||
expect(batchp.fetch_recipients.count).to eq(0)
|
||||
end
|
||||
|
||||
it 'returns user first trigger' do
|
||||
|
||||
user_
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = user_.created_at + batchp.days_past_for_trigger_index(0).days
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(1)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
vals = [1,0,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 0)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(1).days
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(1)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
vals = [0,1,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 1)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(2).days
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(1)
|
||||
vals = [0,0,1]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 2)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
end
|
||||
|
||||
it 'handles existing users' do
|
||||
|
||||
user_existing
|
||||
expect(batchp.fetch_recipients(0).count).to eq(1)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
vals = [1,0,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
|
||||
dd = user_existing.created_at + batchp.days_past_for_trigger_index(0).days
|
||||
Timecop.travel(dd)
|
||||
batchp.make_set(user_existing, 0)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(1).days
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(1)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
vals = [0,1,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_existing, 1)
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(2).days
|
||||
|
|
@ -178,37 +142,27 @@ describe EmailBatch do
|
|||
user_
|
||||
dd = user_.created_at + batchp.days_past_for_trigger_index(1).days
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(1)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
vals = [1,0,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 0)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
2.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(1).days
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(1)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
vals = [0,1,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 1)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(2).days
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(0).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(1).count).to eq(0)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(1)
|
||||
vals = [0,0,1]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 2)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'loop bunch of users' do
|
||||
let(:batchp) {
|
||||
FactoryGirl.create(:email_batch_progression, :sub_type => :client_notdl)
|
||||
}
|
||||
it 'returns no users' do
|
||||
it 'loops bunch of users' do
|
||||
users = []
|
||||
20.times { |nn| users << FactoryGirl.create(:user) }
|
||||
expect(batchp.fetch_recipients(0,5).count).to eq(0)
|
||||
|
|
@ -217,8 +171,129 @@ describe EmailBatch do
|
|||
expect(batchp.fetch_recipients(0,5).count).to eq(20)
|
||||
users.each { |uu| batchp.make_set(uu, 0) }
|
||||
expect(batchp.fetch_recipients(0,5).count).to eq(0)
|
||||
users.map &:destroy
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe 'client downloaded, not run' do
|
||||
# before { pending }
|
||||
|
||||
let(:batchp) {
|
||||
FactoryGirl.create(:email_batch_progression, :sub_type => :client_dl_notrun)
|
||||
}
|
||||
let(:user_) { FactoryGirl.create(:user, :first_downloaded_client_at => Time.now) }
|
||||
let(:date_in_past) { Time.now - (2 * batchp.days_past_for_trigger_index(2)).days }
|
||||
let(:user_existing) {
|
||||
FactoryGirl.create(:user,
|
||||
:created_at => date_in_past,
|
||||
:first_downloaded_client_at => date_in_past)
|
||||
}
|
||||
|
||||
after(:each) do
|
||||
batchp.clear_batch_sets!
|
||||
Timecop.return
|
||||
end
|
||||
|
||||
describe 'one at a time' do
|
||||
pending
|
||||
it 'sends one email' do
|
||||
user_existing
|
||||
batchp.deliver_batch
|
||||
expect(ProgressMailer.deliveries.length).to eq(1)
|
||||
end
|
||||
end
|
||||
|
||||
it 'returns new user triggers' do
|
||||
user_
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = user_.created_at + batchp.days_past_for_trigger_index(0).days
|
||||
Timecop.travel(dd)
|
||||
vals = [1,0,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 0)
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(1).days
|
||||
Timecop.travel(dd)
|
||||
vals = [0,1,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 1)
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(2).days
|
||||
Timecop.travel(dd)
|
||||
vals = [0,0,1]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 2)
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
end
|
||||
|
||||
it 'handles existing users' do
|
||||
user_existing
|
||||
vals = [1,0,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
|
||||
dd = user_existing.created_at + batchp.days_past_for_trigger_index(0).days
|
||||
Timecop.travel(dd)
|
||||
batchp.make_set(user_existing, 0)
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(1).days
|
||||
Timecop.travel(dd)
|
||||
vals = [0,1,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_existing, 1)
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(2).days
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(1)
|
||||
batchp.make_set(user_existing, 2)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
|
||||
dd = dd + 1
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
end
|
||||
|
||||
it 'skips some days' do
|
||||
user_
|
||||
dd = user_.created_at + batchp.days_past_for_trigger_index(1).days
|
||||
Timecop.travel(dd)
|
||||
vals = [1,0,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 0)
|
||||
2.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(0) }
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(1).days
|
||||
Timecop.travel(dd)
|
||||
vals = [0,1,0]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 1)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
|
||||
dd = dd + batchp.days_past_for_trigger_index(2).days
|
||||
Timecop.travel(dd)
|
||||
vals = [0,0,1]
|
||||
3.times { |nn| expect(batchp.fetch_recipients(nn).count).to eq(vals[nn]) }
|
||||
batchp.make_set(user_, 2)
|
||||
expect(batchp.fetch_recipients(2).count).to eq(0)
|
||||
end
|
||||
|
||||
it 'loop bunch of users' do
|
||||
pending
|
||||
users = []
|
||||
20.times { |nn| users << FactoryGirl.create(:user) }
|
||||
expect(batchp.fetch_recipients(0,5).count).to eq(0)
|
||||
dd = users[0].created_at + batchp.days_past_for_trigger_index(0).days
|
||||
Timecop.travel(dd)
|
||||
expect(batchp.fetch_recipients(0,5).count).to eq(20)
|
||||
users.each { |uu| batchp.make_set(uu, 0) }
|
||||
expect(batchp.fetch_recipients(0,5).count).to eq(0)
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue