onboarding survey

This commit is contained in:
Seth Call 2018-02-25 21:44:02 -06:00
parent 89f69cfdca
commit 698e643996
6 changed files with 96 additions and 3 deletions

View File

@ -10,6 +10,7 @@ ActiveAdmin.register_page "Dashboard" do
li link_to "Users", admin_users_path
li link_to "Teachers", admin_teachers_path
li link_to "Onboarding Management", admin_onboarder_managements_path
li link_to "Onboarding Settings", admin_onboarders_path
li link_to "Lesson Sessions", admin_lesson_sessions_path
li link_to "Slow Lesson Responses", admin_slow_responses_path

View File

@ -1,5 +1,3 @@
<% provide(:title, @subject) %>
<% if !@user.anonymous? %>
<p>Hi <%= @user.first_name %>,

View File

@ -339,9 +339,25 @@ module JamRuby
updates[:stuck_take_plesson] = false
end
if updates[:onboarding_status] == ONBOARDING_STATUS_ONBOARDED || updates[:onboarding_status] == ONBOARDING_STATUS_LOST || updates[:onboarding_status] == ONBOARDING_STATUS_ESCALATED
self.send_onboarding_survey = true
end
User.where(id: self.id).update_all(updates)
end
end
def self.hourly_check
send_onboarding_surveys
end
def self.send_onboarding_surveys
User.where(send_onboarding_survey: true, sent_onboarding_survey_at: nil).each do |user|
UserMailer.onboarding_survey(user).deliver_now
User.where(id: user.id).update_all(sent_onboarding_survey_at: Time.now)
end
end
def update_teacher_pct
if teacher
teacher.update_profile_pct

View File

@ -11,7 +11,7 @@ module JamRuby
LessonBooking.hourly_check
LessonSession.hourly_check
TeacherPayment.hourly_check
User.hourly_check
@@log.debug("done")
end

View File

@ -931,6 +931,78 @@ describe User do
end
end
end
describe "onboarding_status" do
let(:user) {FactoryGirl.create(:user)}
it "onboarded" do
user.send_onboarding_survey.should be_false
user.onboarding_onboarded_at = Time.now
user.save!
user.send_onboarding_survey.should be_true
user.onboarding_status = User::ONBOARDING_STATUS_ONBOARDED
end
it "lost" do
user.send_onboarding_survey.should be_false
user.onboarding_lost_reason = User::LOST_REASON_NO_VIDEO_STREAM
user.save!
user.send_onboarding_survey.should be_true
user.onboarding_status = User::ONBOARDING_STATUS_LOST
end
it "escalated" do
user.send_onboarding_survey.should be_false
user.onboarding_escalation_reason = User::ESCALATION_REASON_NO_VIDEO_STREAM
user.save!
user.send_onboarding_survey.should be_true
user.onboarding_status = User::ONBOARDING_STATUS_ESCALATED
end
it "taken free lesson" do
user.send_onboarding_survey.should be_false
user.first_onboarding_free_lesson_at = Time.now
user.save!
user.send_onboarding_survey.should be_false
user.onboarding_status = User::ONBOARDING_STATUS_FREE_LESSON
end
it "paid lesson" do
user.send_onboarding_survey.should be_false
user.first_onboarding_paid_lesson_at = Time.now
user.save!
user.send_onboarding_survey.should be_false
user.onboarding_status = User::ONBOARDING_STATUS_PAID_LESSON
end
it "assigned" do
user.send_onboarding_survey.should be_false
user.onboarder = FactoryGirl.create(:user, is_onboarder:true)
user.save!
user.send_onboarding_survey.should be_false
user.onboarding_status = User::ONBOARDING_STATUS_ASSIGNED
end
end
describe "send_onboarding_surveys" do
let(:user) {FactoryGirl.create(:user)}
it "works" do
UserMailer.deliveries.clear
user.send_onboarding_survey = true
user.save!
User.send_onboarding_surveys
UserMailer.deliveries.count.should eql 1
user.reload
user.send_onboarding_survey.should be_true
user.sent_onboarding_survey_at.should_not be_nil
UserMailer.deliveries.clear
User.send_onboarding_surveys
UserMailer.deliveries.count.should eql 0
end
end
=begin
describe "update avatar" do

View File

@ -317,6 +317,12 @@ describe "RenderMailers", :slow => true do
UserMailer.deliveries.clear
UserMailer.take_paid_lesson(user).deliver_now
end
it "onboarding_survey" do
@filename = "onboarding_survey"
UserMailer.deliveries.clear
UserMailer.onboarding_survey(user).deliver_now
end
end
end