VRFS-3300 : Reminder mails on user mailer. Also add tests to spec.
This commit is contained in:
parent
ed487e11a3
commit
521b0f4ba7
|
|
@ -182,7 +182,7 @@
|
|||
email = user.email
|
||||
subject = "Your band has a new follower on JamKazam"
|
||||
unique_args = {:type => "new_band_follower"}
|
||||
|
||||
|
||||
@body = msg
|
||||
sendgrid_category "Notification"
|
||||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
|
@ -390,13 +390,23 @@
|
|||
end
|
||||
end
|
||||
|
||||
def scheduled_session_reminder(user, msg, session)
|
||||
def scheduled_session_reminder_upcoming(user, session)
|
||||
subject = "Your JamKazam session starts in 1 hour!"
|
||||
unique_args = {:type => "scheduled_session_reminder_upcoming"}
|
||||
send_scheduled_session_reminder(user, session, subject, unique_args)
|
||||
end
|
||||
|
||||
def scheduled_session_reminder_day(user, session)
|
||||
subject = "JamKazam Session Reminder"
|
||||
unique_args = {:type => "scheduled_session_reminder_day"}
|
||||
send_scheduled_session_reminder(user, session, subject, unique_args)
|
||||
end
|
||||
|
||||
def send_scheduled_session_reminder(user, session, subject, unique_args)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Session Rescheduled"
|
||||
unique_args = {:type => "scheduled_session_reminder"}
|
||||
@body = msg
|
||||
@user = user
|
||||
@session_name = session.name
|
||||
@session_date = session.pretty_scheduled_start(true)
|
||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session.id}/details"
|
||||
|
|
@ -448,7 +458,7 @@
|
|||
@sessions_and_latency = sessions_and_latency
|
||||
|
||||
@title = 'New Scheduled Sessions Matched to You'
|
||||
mail(:to => receiver.email,
|
||||
mail(:to => receiver.email,
|
||||
:subject => EmailBatchScheduledSessions.subject) do |format|
|
||||
format.text
|
||||
format.html
|
||||
|
|
@ -461,7 +471,7 @@
|
|||
email = user.email
|
||||
subject = "A band that you follow has joined a session"
|
||||
unique_args = {:type => "band_session_join"}
|
||||
|
||||
|
||||
@body = msg
|
||||
@session_url = "#{APP_CONFIG.external_root_url}/sessions/#{session_id}"
|
||||
sendgrid_category "Notification"
|
||||
|
|
@ -482,7 +492,7 @@
|
|||
email = user.email
|
||||
subject = "A musician has saved a new recording on JamKazam"
|
||||
unique_args = {:type => "musician_recording_saved"}
|
||||
|
||||
|
||||
@body = msg
|
||||
sendgrid_category "Notification"
|
||||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
|
@ -502,7 +512,7 @@
|
|||
email = user.email
|
||||
subject = "A band has saved a new recording on JamKazam"
|
||||
unique_args = {:type => "band_recording_saved"}
|
||||
|
||||
|
||||
@body = msg
|
||||
sendgrid_category "Notification"
|
||||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
|
@ -522,7 +532,7 @@
|
|||
email = user.email
|
||||
subject = "You have been invited to join a band on JamKazam"
|
||||
unique_args = {:type => "band_invitation"}
|
||||
|
||||
|
||||
@body = msg
|
||||
sendgrid_category "Notification"
|
||||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
<% provide(:title, 'Scheduled Session Reminder') %>
|
||||
|
||||
<p><%= @body %></p>
|
||||
|
||||
<p>
|
||||
<%= @session_name %><br/>
|
||||
<%= @session_date %>
|
||||
</p>
|
||||
|
||||
<p><a style="color: #ffcc00;" href="<%= @session_url %>">View Session Details</a></p>
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
<%= @body %>
|
||||
|
||||
<%= @session_name %>
|
||||
<%= @session_date %>
|
||||
|
||||
See session details at <%= @session_url %>.
|
||||
|
|
@ -0,0 +1,18 @@
|
|||
<% provide(:title, 'JamKazam Session Reminder') %>
|
||||
|
||||
|
||||
<div>
|
||||
Hi <%= @user.first_name %>,
|
||||
</div>
|
||||
<br/>
|
||||
<div>
|
||||
<span>This is a reminder that your JamKazam session</span>
|
||||
<a href='<%=@session_url%>'><%= @session_name %></a>
|
||||
<span>is scheduled for tomorrow. We hope you have fun!</span>
|
||||
</div>
|
||||
<br/>
|
||||
<div>
|
||||
Best Regards,
|
||||
<br/>
|
||||
Team JamKazam
|
||||
</div>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
Hi <%= @user.first_name %>,
|
||||
|
||||
This is a reminder that your JamKazam session <%=@session_name%> is scheduled for tomorrow. We hope you have fun!
|
||||
|
||||
Best Regards,
|
||||
Team JamKazam
|
||||
|
||||
See session details at <%= @session_url %>.
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
<% provide(:title, 'Your JamKazam session starts in 1 hour!') %>
|
||||
|
||||
<div>
|
||||
Hi <%= @user.first_name %>,
|
||||
</div>
|
||||
<br/>
|
||||
<div>
|
||||
<span>This is a reminder that your JamKazam session</span>
|
||||
<a href='<%=@session_url%>'><%= @session_name %></a>
|
||||
<span>starts in 1 hour. We hope you have fun!</span>
|
||||
</div>
|
||||
<br/>
|
||||
<div>
|
||||
Best Regards,
|
||||
<br/>
|
||||
Team JamKazam
|
||||
</div>
|
||||
|
|
@ -0,0 +1,10 @@
|
|||
Hi <%= @user.first_name %>,
|
||||
|
||||
This is a reminder that your JamKazam session
|
||||
<%=@session_name%>
|
||||
starts in 1 hour. We hope you have fun!
|
||||
|
||||
Best Regards,
|
||||
Team JamKazam
|
||||
|
||||
See session details at <%= @session_url %>.
|
||||
|
|
@ -123,7 +123,7 @@ describe UserMailer do
|
|||
|
||||
before(:each) do
|
||||
user.update_email = "my_new_email@jamkazam.com"
|
||||
UserMailer.updating_email(user).deliver
|
||||
UserMailer.updating_email(user).deliver
|
||||
end
|
||||
|
||||
it { UserMailer.deliveries.length.should == 1 }
|
||||
|
|
@ -137,6 +137,48 @@ describe UserMailer do
|
|||
it { mail.text_part.body.include?("to confirm your change in email").should be_true }
|
||||
end
|
||||
|
||||
describe "notifications" do
|
||||
|
||||
let(:mail) { UserMailer.deliveries[0] }
|
||||
let(:music_session) { FactoryGirl.create(:music_session) }
|
||||
|
||||
it "should send upcoming email" do
|
||||
user.update_email = "my_new_email@jamkazam.com"
|
||||
UserMailer.scheduled_session_reminder_upcoming(music_session.creator, music_session).deliver
|
||||
UserMailer.deliveries.length.should == 1
|
||||
|
||||
mail['from'].to_s.should == UserMailer::DEFAULT_SENDER
|
||||
mail['to'].to_s.should == music_session.creator.email# rsvp_requests.first.user.email
|
||||
mail.multipart?.should == true # because we send plain + htm
|
||||
|
||||
# verify that the messages are correctly configured
|
||||
mail.html_part.body.include?("This is a reminder that your JamKazam session").should be_true
|
||||
mail.text_part.body.include?("This is a reminder that your JamKazam session").should be_true
|
||||
mail.html_part.body.include?("starts in 1 hour").should be_true
|
||||
mail.text_part.body.include?("starts in 1 hour").should be_true
|
||||
|
||||
|
||||
end
|
||||
|
||||
it "should send 1-day reminder" do
|
||||
user.update_email = "my_new_email@jamkazam.com"
|
||||
UserMailer.scheduled_session_reminder_day(music_session.creator, music_session).deliver
|
||||
UserMailer.deliveries.length.should == 1
|
||||
|
||||
mail['from'].to_s.should == UserMailer::DEFAULT_SENDER
|
||||
mail['to'].to_s.should == music_session.creator.email# rsvp_requests.first.user.email
|
||||
mail.multipart?.should == true # because we send plain + htm
|
||||
|
||||
# verify that the messages are correctly configured
|
||||
mail.html_part.body.include?("This is a reminder that your JamKazam session").should be_true
|
||||
mail.text_part.body.include?("This is a reminder that your JamKazam session").should be_true
|
||||
mail.html_part.body.include?("is scheduled for tomorrow").should be_true
|
||||
mail.text_part.body.include?("is scheduled for tomorrow").should be_true
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
|
||||
# describe "sends new musicians email" do
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue