VRFS-2140 do not send any email notifications if the user has opted out of receiving emails
This commit is contained in:
parent
14960eb8ae
commit
a7623aac26
|
|
@ -115,7 +115,10 @@
|
|||
end
|
||||
|
||||
#################################### NOTIFICATION EMAILS ####################################
|
||||
def friend_request(email, msg, friend_request_id)
|
||||
def friend_request(user, msg, friend_request_id)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "You have a new friend request on JamKazam"
|
||||
unique_args = {:type => "friend_request"}
|
||||
|
||||
|
|
@ -125,7 +128,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -133,7 +136,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def friend_request_accepted(email, msg)
|
||||
def friend_request_accepted(user, msg)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "You have a new friend on JamKazam"
|
||||
unique_args = {:type => "friend_request_accepted"}
|
||||
|
||||
|
|
@ -142,7 +148,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -150,7 +156,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def new_user_follower(email, msg)
|
||||
def new_user_follower(user, msg)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "You have a new follower on JamKazam"
|
||||
unique_args = {:type => "new_user_follower"}
|
||||
|
||||
|
|
@ -159,7 +168,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -167,7 +176,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def new_band_follower(email, msg)
|
||||
def new_band_follower(user, msg)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Your band has a new follower on JamKazam"
|
||||
unique_args = {:type => "new_band_follower"}
|
||||
|
||||
|
|
@ -176,15 +188,18 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:bcc => email, :subject => subject) do |format|
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def session_invitation(email, msg)
|
||||
def session_invitation(user, msg)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "You have been invited to a session on JamKazam"
|
||||
unique_args = {:type => "session_invitation"}
|
||||
|
||||
|
|
@ -193,7 +208,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -201,7 +216,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def musician_session_join(email, msg, session_id)
|
||||
def musician_session_join(user, msg, session_id)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Someone you know is in a session on JamKazam"
|
||||
unique_args = {:type => "musician_session_join"}
|
||||
@body = msg
|
||||
|
|
@ -210,15 +228,18 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:bcc => email, :subject => subject) do |format|
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def scheduled_session_invitation(email, msg, session)
|
||||
def scheduled_session_invitation(user, msg, session)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Session Invitation"
|
||||
unique_args = {:type => "scheduled_session_invitation"}
|
||||
@body = msg
|
||||
|
|
@ -229,7 +250,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -237,7 +258,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def scheduled_session_rsvp(email, msg, session)
|
||||
def scheduled_session_rsvp(user, msg, session)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Session RSVP"
|
||||
unique_args = {:type => "scheduled_session_rsvp"}
|
||||
@body = msg
|
||||
|
|
@ -248,7 +272,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -256,7 +280,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def scheduled_session_rsvp_approved(email, msg, session)
|
||||
def scheduled_session_rsvp_approved(user, msg, session)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Session RSVP Approved"
|
||||
unique_args = {:type => "scheduled_session_rsvp_approved"}
|
||||
@body = msg
|
||||
|
|
@ -267,7 +294,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -275,7 +302,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def scheduled_session_rsvp_cancelled(email, msg, session)
|
||||
def scheduled_session_rsvp_cancelled(user, msg, session)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Session RSVP Cancelled"
|
||||
unique_args = {:type => "scheduled_session_rsvp_cancelled"}
|
||||
@body = msg
|
||||
|
|
@ -286,7 +316,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -294,7 +324,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def scheduled_session_rsvp_cancelled_org(email, msg, session)
|
||||
def scheduled_session_rsvp_cancelled_org(user, msg, session)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Your Session RSVP Cancelled"
|
||||
unique_args = {:type => "scheduled_session_rsvp_cancelled_org"}
|
||||
@body = msg
|
||||
|
|
@ -305,7 +338,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -313,7 +346,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def scheduled_session_cancelled(email, msg, session)
|
||||
def scheduled_session_cancelled(user, msg, session)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Session Cancelled"
|
||||
unique_args = {:type => "scheduled_session_cancelled"}
|
||||
@body = msg
|
||||
|
|
@ -324,7 +360,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -332,7 +368,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def scheduled_session_rescheduled(email, msg, session)
|
||||
def scheduled_session_rescheduled(user, msg, session)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Session Rescheduled"
|
||||
unique_args = {:type => "scheduled_session_rescheduled"}
|
||||
@body = msg
|
||||
|
|
@ -343,7 +382,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -351,7 +390,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def scheduled_session_reminder(email, msg, session)
|
||||
def scheduled_session_reminder(user, msg, session)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Session Rescheduled"
|
||||
unique_args = {:type => "scheduled_session_reminder"}
|
||||
@body = msg
|
||||
|
|
@ -362,7 +404,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -370,7 +412,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def scheduled_session_comment(email, msg, comment, session)
|
||||
def scheduled_session_comment(user, msg, comment, session)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "New Session Comment"
|
||||
unique_args = {:type => "scheduled_session_comment"}
|
||||
@body = msg
|
||||
|
|
@ -382,7 +427,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -408,7 +453,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def band_session_join(email, msg, session_id)
|
||||
def band_session_join(user, msg, session_id)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "A band that you follow has joined a session"
|
||||
unique_args = {:type => "band_session_join"}
|
||||
|
||||
|
|
@ -418,15 +466,18 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:bcc => email, :subject => subject) do |format|
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def musician_recording_saved(email, msg)
|
||||
def musician_recording_saved(user, msg)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "A musician has saved a new recording on JamKazam"
|
||||
unique_args = {:type => "musician_recording_saved"}
|
||||
|
||||
|
|
@ -435,15 +486,18 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:bcc => email, :subject => subject) do |format|
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def band_recording_saved(email, msg)
|
||||
def band_recording_saved(user, msg)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "A band has saved a new recording on JamKazam"
|
||||
unique_args = {:type => "band_recording_saved"}
|
||||
|
||||
|
|
@ -452,15 +506,18 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:bcc => email, :subject => subject) do |format|
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
format.html
|
||||
end
|
||||
end
|
||||
|
||||
def band_invitation(email, msg)
|
||||
def band_invitation(user, msg)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "You have been invited to join a band on JamKazam"
|
||||
unique_args = {:type => "band_invitation"}
|
||||
|
||||
|
|
@ -469,7 +526,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -477,7 +534,10 @@
|
|||
end
|
||||
end
|
||||
|
||||
def band_invitation_accepted(email, msg)
|
||||
def band_invitation_accepted(user, msg)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Your band invitation was accepted"
|
||||
unique_args = {:type => "band_invitation_accepted"}
|
||||
|
||||
|
|
@ -486,7 +546,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
@ -495,7 +555,10 @@
|
|||
end
|
||||
|
||||
|
||||
def text_message(email, sender_id, sender_name, sender_photo_url, message)
|
||||
def text_message(user, sender_id, sender_name, sender_photo_url, message)
|
||||
return if !user.subscribe_email
|
||||
|
||||
email = user.email
|
||||
subject = "Message from #{sender_name}"
|
||||
unique_args = {:type => "text_message"}
|
||||
|
||||
|
|
@ -508,7 +571,7 @@
|
|||
sendgrid_unique_args :type => unique_args[:type]
|
||||
|
||||
sendgrid_recipients([email])
|
||||
sendgrid_substitute('@USERID', [User.id_for_email(email)])
|
||||
sendgrid_substitute('@USERID', [user.id])
|
||||
|
||||
mail(:to => email, :subject => subject) do |format|
|
||||
format.text
|
||||
|
|
|
|||
|
|
@ -277,7 +277,11 @@ module JamRuby
|
|||
|
||||
@@mq_router.publish_to_user(friend_id, msg)
|
||||
else
|
||||
UserMailer.friend_request(friend.email, notification_msg, friend_request_id).deliver
|
||||
begin
|
||||
UserMailer.friend_request(friend, notification_msg, friend_request_id).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send FRIEND_REQUEST email to offline user #{friend.email} #{e}")
|
||||
end
|
||||
end
|
||||
notification
|
||||
end
|
||||
|
|
@ -306,7 +310,11 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(user.id, msg)
|
||||
|
||||
else
|
||||
UserMailer.friend_request_accepted(user.email, notification_msg).deliver
|
||||
begin
|
||||
UserMailer.friend_request_accepted(user, notification_msg).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send FRIEND_REQUEST_ACCEPTED email to offline user #{user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -333,7 +341,11 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(user.id, msg)
|
||||
|
||||
else
|
||||
UserMailer.new_user_follower(user.email, notification_msg).deliver
|
||||
begin
|
||||
UserMailer.new_user_follower(user, notification_msg).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send NEW_USER_FOLLOWER email to offline user #{user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -356,7 +368,8 @@ module JamRuby
|
|||
# this protects against sending the notification to a band member who decides to follow the band
|
||||
if follower.id != bm.user.id
|
||||
if bm.user.online
|
||||
msg = @@message_factory.new_user_follower(
|
||||
|
||||
msg = @@message_factory.new_band_follower(
|
||||
bm.user_id,
|
||||
follower.photo_url,
|
||||
notification_msg,
|
||||
|
|
@ -367,7 +380,11 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(bm.user_id, msg)
|
||||
|
||||
else
|
||||
UserMailer.new_band_follower(bm.user.email, notification_msg).deliver
|
||||
begin
|
||||
UserMailer.new_band_follower(bm.user, notification_msg).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send NEW_BAND_FOLLOWER email to offline user #{bm.user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -396,7 +413,11 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(receiver.id, msg)
|
||||
|
||||
else
|
||||
UserMailer.session_invitation(receiver.email, notification_msg).deliver
|
||||
begin
|
||||
UserMailer.session_invitation(receiver, notification_msg).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send SESSION_INVITATION email to user #{receiver.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -536,7 +557,7 @@ module JamRuby
|
|||
friends_and_followers = friend_users.concat(follower_users).uniq
|
||||
|
||||
# remove anyone in the session and invited musicians
|
||||
friends_and_followers = friends_and_followers - music_session.users - music_session.invited_musicians
|
||||
friends_and_followers = friends_and_followers - music_session.unique_users - music_session.invited_musicians
|
||||
notifications, online_ff, offline_ff = [], [], []
|
||||
notification_msg = format_msg(NotificationTypes::MUSICIAN_SESSION_JOIN, {:user => user})
|
||||
|
||||
|
|
@ -568,11 +589,13 @@ module JamRuby
|
|||
end
|
||||
|
||||
# send email notifications
|
||||
if !offline_ff.empty? && music_session.fan_access
|
||||
if APP_CONFIG.send_join_session_email_notifications
|
||||
begin
|
||||
UserMailer.musician_session_join(offline_ff.map! {|f| f.email}, notification_msg, music_session.id).deliver if APP_CONFIG.send_join_session_email_notifications
|
||||
offline_ff.each do |f|
|
||||
UserMailer.musician_session_join(f, notification_msg, music_session.id).deliver
|
||||
end
|
||||
rescue => e
|
||||
@@log.error("unable to send email to offline participants #{e}")
|
||||
@@log.error("Unable to send MUSICIAN_SESSION_JOIN email to user #{f.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -608,9 +631,9 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_invitation(target_user.email, notification_msg, music_session).deliver
|
||||
UserMailer.scheduled_session_invitation(target_user, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_invitation email to offline user #{target_user.email} #{e}")
|
||||
@@log.error("Unable to send SCHEDULED_SESSION_INVITATION email to user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -623,6 +646,8 @@ module JamRuby
|
|||
|
||||
return if target_user == source_user
|
||||
|
||||
instruments = [] if instruments.nil?
|
||||
|
||||
notification = Notification.new
|
||||
notification.description = NotificationTypes::SCHEDULED_SESSION_RSVP
|
||||
notification.source_user_id = source_user.id
|
||||
|
|
@ -647,9 +672,9 @@ module JamRuby
|
|||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp(target_user.email, notification_msg, music_session).deliver
|
||||
UserMailer.scheduled_session_rsvp(target_user, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rsvp email to offline user #{target_user.email} #{e}")
|
||||
@@log.error("Unable to send SCHEDULED_SESSION_RSVP email to user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -660,6 +685,10 @@ module JamRuby
|
|||
target_user = user
|
||||
source_user = music_session.creator
|
||||
|
||||
return if target_user == source_user
|
||||
|
||||
instruments = [] if instruments.nil?
|
||||
|
||||
notification = Notification.new
|
||||
notification.description = NotificationTypes::SCHEDULED_SESSION_RSVP_APPROVED
|
||||
notification.source_user_id = source_user.id
|
||||
|
|
@ -681,9 +710,9 @@ module JamRuby
|
|||
|
||||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp_approved(target_user.email, notification_msg, music_session).deliver
|
||||
UserMailer.scheduled_session_rsvp_approved(target_user, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rsvp_approved email to offline user #{target_user.email} #{e}")
|
||||
@@log.error("Unable to send SCHEDULED_SESSION_RSVP_APPROVED email to user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -716,9 +745,9 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp_cancelled(target_user.email, notification_msg, music_session).deliver
|
||||
UserMailer.scheduled_session_rsvp_cancelled(target_user, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send send_scheduled_session_rsvp_cancelled email to offline user #{target_user.email} #{e}")
|
||||
@@log.error("Unable to send SCHEDULED_SESSION_RSVP_CANCELLED email to user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -751,9 +780,9 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_rsvp_cancelled_org(target_user.email, notification_msg, music_session).deliver
|
||||
UserMailer.scheduled_session_rsvp_cancelled_org(target_user, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rsvp_cancelled_org email to offline user #{target_user.email} #{e}")
|
||||
@@log.error("Unable to send SCHEDULED_SESSION_RSVP_CANCELLED_ORG email to user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -792,9 +821,9 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_cancelled(target_user.email, notification_msg, music_session).deliver
|
||||
UserMailer.scheduled_session_cancelled(target_user, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_cancelled email to offline user #{target_user.email} #{e}")
|
||||
@@log.error("Unable to send SCHEDULED_SESSION_CANCELLED email to user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -808,7 +837,7 @@ module JamRuby
|
|||
pending_invites = music_session.pending_invitations
|
||||
|
||||
# remove the creator from the array
|
||||
target_users = target_users.uniq.concat(pending_invites) - [music_session.creator]
|
||||
target_users = target_users.concat(pending_invites).uniq - [music_session.creator]
|
||||
|
||||
target_users.each do |target_user|
|
||||
source_user = music_session.creator
|
||||
|
|
@ -835,9 +864,9 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_rescheduled(target_user.email, notification_msg, music_session).deliver
|
||||
UserMailer.scheduled_session_rescheduled(target_user, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_rescheduled email to offline user #{target_user.email} #{e}")
|
||||
@@log.error("Unable to send SCHEDULED_SESSION_RESCHEDULED email to offline user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -877,9 +906,9 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_reminder(target_user.email, notification_msg, music_session).deliver
|
||||
UserMailer.scheduled_session_reminder(target_user, notification_msg, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_reminder email to offline user #{target_user.email} #{e}")
|
||||
@@log.error("Unable to send SCHEDULED_SESSION_REMINDER email to user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -894,7 +923,7 @@ module JamRuby
|
|||
pending_invites = music_session.pending_invitations
|
||||
|
||||
# remove the creator from the array
|
||||
target_users = target_users.uniq.concat(pending_invites) - [creator]
|
||||
target_users = target_users.concat(pending_invites).uniq - [creator]
|
||||
|
||||
target_users.each do |target_user|
|
||||
source_user = creator
|
||||
|
|
@ -923,9 +952,9 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(target_user.id, msg)
|
||||
|
||||
begin
|
||||
UserMailer.scheduled_session_comment(target_user.email, notification_msg, comment, music_session).deliver
|
||||
UserMailer.scheduled_session_comment(target_user, notification_msg, comment, music_session).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send scheduled_session_comment email to offline user #{target_user.email} #{e}")
|
||||
@@log.error("Unable to send SCHEDULED_SESSION_COMMENT email to user #{target_user.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -972,8 +1001,14 @@ module JamRuby
|
|||
end
|
||||
|
||||
# send email notifications
|
||||
if !offline_followers.empty? && music_session.fan_access
|
||||
UserMailer.band_session_join(offline_followers.map! {|f| f.email}, notification_msg, music_session.id).deliver if APP_CONFIG.send_join_session_email_notifications
|
||||
if !offline_followers.empty? && music_session.fan_access && APP_CONFIG.send_join_session_email_notifications
|
||||
offline_followers.each do |f|
|
||||
begin
|
||||
UserMailer.band_session_join(f, notification_msg, music_session.id).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send BAND_SESSION_JOIN email to user #{f.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -1018,8 +1053,12 @@ module JamRuby
|
|||
end
|
||||
|
||||
# send email notifications
|
||||
unless offline_ff.empty?
|
||||
UserMailer.musician_recording_saved(offline_ff.map! {|f| f.email}, notification_msg).deliver
|
||||
offline_ff.each do |f|
|
||||
begin
|
||||
UserMailer.musician_recording_saved(f, notification_msg).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send MUSICIAN_RECORDING_SAVED email to user #{f.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1053,8 +1092,12 @@ module JamRuby
|
|||
end
|
||||
|
||||
# send email notifications
|
||||
unless offline_followers.empty?
|
||||
UserMailer.band_recording_saved(offline_followers.map! {|f| f.email}, notification_msg).deliver
|
||||
offline_ff.each do |f|
|
||||
begin
|
||||
UserMailer.band_recording_saved(f, notification_msg).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send BAND_RECORDING_SAVED email to user #{f.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1149,7 +1192,11 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(receiver.id, msg)
|
||||
|
||||
else
|
||||
UserMailer.text_message(receiver.email, sender.id, sender.name, sender.resolved_photo_url, message).deliver
|
||||
begin
|
||||
UserMailer.text_message(receiver, sender.id, sender.name, sender.resolved_photo_url, message).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send TEXT_MESSAGE email to user #{receiver.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1182,7 +1229,11 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(receiver.id, msg)
|
||||
|
||||
else
|
||||
UserMailer.band_invitation(receiver.email, notification_msg).deliver
|
||||
begin
|
||||
UserMailer.band_invitation(receiver, notification_msg).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send band_invitation email to offline user #{receiver.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -1209,7 +1260,11 @@ module JamRuby
|
|||
@@mq_router.publish_to_user(receiver.id, msg)
|
||||
|
||||
else
|
||||
UserMailer.band_invitation_accepted(receiver.email, notification_msg).deliver
|
||||
begin
|
||||
UserMailer.band_invitation_accepted(receiver, notification_msg).deliver
|
||||
rescue => e
|
||||
@@log.error("Unable to send band_invitation_accepted email to offline user #{receiver.email} #{e}")
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ describe Notification do
|
|||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:friend_request) {FactoryGirl.create(:friend_request, user:sender, friend:receiver)}
|
||||
|
||||
it "success when offline" do
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_friend_request(friend_request.id, sender.id, receiver.id)
|
||||
|
||||
|
|
@ -30,6 +30,17 @@ describe Notification do
|
|||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
receiver.subscribe_email = false
|
||||
receiver.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_friend_request(friend_request.id, sender.id, receiver.id)
|
||||
|
||||
notification.errors.any?.should be_false
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "success when online" do
|
||||
receiver_connection = FactoryGirl.create(:connection, user: receiver)
|
||||
|
|
@ -42,6 +53,622 @@ describe Notification do
|
|||
end
|
||||
end
|
||||
|
||||
describe "send friend request accepted" do
|
||||
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:friend_request) {FactoryGirl.create(:friend_request, user:sender, friend:receiver)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_friend_request_accepted(receiver.id, sender.id)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
receiver.subscribe_email = false
|
||||
receiver.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_friend_request_accepted(receiver.id, sender.id)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send new user follower" do
|
||||
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_new_user_follower(sender, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
receiver.subscribe_email = false
|
||||
receiver.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_new_user_follower(sender, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send new band follower" do
|
||||
let(:member) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:band) {FactoryGirl.create(:band)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
band.users << member
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_new_band_follower(sender, band)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
member.subscribe_email = false
|
||||
member.save!
|
||||
|
||||
band.users << member
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_new_band_follower(sender, band)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send session invitation" do
|
||||
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_session_invitation(receiver, sender, session.id)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
receiver.subscribe_email = false
|
||||
receiver.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_session_invitation(receiver, sender, session.id)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send musician session join" do
|
||||
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
FactoryGirl.create(:friendship, :user => receiver, :friend => sender)
|
||||
FactoryGirl.create(:friendship, :user => sender, :friend => receiver)
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_musician_session_join(session, sender)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
FactoryGirl.create(:friendship, :user => receiver, :friend => sender)
|
||||
FactoryGirl.create(:friendship, :user => sender, :friend => receiver)
|
||||
|
||||
receiver.subscribe_email = false
|
||||
receiver.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
Notification.send_musician_session_join(session, sender)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send band session join" do
|
||||
let(:follower) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:band) {FactoryGirl.create(:band)}
|
||||
|
||||
# it "sends email when user is offline and subscribes to emails" do
|
||||
# band.followers << follower
|
||||
# band.users << sender
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# Notification.send_band_session_join(session, band)
|
||||
|
||||
# UserMailer.deliveries.length.should == 1
|
||||
# calls[:count].should == 0
|
||||
# end
|
||||
|
||||
# it "does not send email when user is offline and opts out of emails" do
|
||||
# follower.subscribe_email = false
|
||||
# follower.save!
|
||||
|
||||
# band.followers << follower
|
||||
# band.users << sender
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# Notification.send_band_session_join(session, band)
|
||||
|
||||
# UserMailer.deliveries.length.should == 0
|
||||
# calls[:count].should == 0
|
||||
# end
|
||||
end
|
||||
|
||||
describe "send musician recording saved join" do
|
||||
end
|
||||
|
||||
describe "send band recording saved join" do
|
||||
end
|
||||
|
||||
describe "send band invitation" do
|
||||
end
|
||||
|
||||
describe "send band invitation accepted" do
|
||||
end
|
||||
|
||||
describe "send scheduled session invitation" do
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_invitation(session, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
receiver.subscribe_email = false
|
||||
receiver.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_invitation(session, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_invitation(nil, sender)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_invitation(session, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rsvp" do
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp(session, receiver, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
session.creator.subscribe_email = false
|
||||
session.creator.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp(session, receiver, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp(nil, receiver, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp(session, nil, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rsvp approved" do
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_approved(session, receiver, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
receiver.subscribe_email = false
|
||||
receiver.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_approved(session, receiver, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_approved(nil, receiver, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_approved(session, nil, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rsvp cancellation" do
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled(session, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
session.creator.subscribe_email = false
|
||||
session.creator.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled(session, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled(nil, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled(session, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rsvp cancellation by organizer" do
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
it "sends email when user is offline and subscribes to emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled_org(session, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 1
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "does not send email when user is offline and opts out of emails" do
|
||||
session.creator = sender
|
||||
session.save!
|
||||
|
||||
receiver.subscribe_email = false
|
||||
receiver.save!
|
||||
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled_org(session, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 1
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled_org(nil, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled_org(session, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session cancellation" do
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
# it "sends email when user is offline and subscribes to emails" do
|
||||
# session.creator = sender
|
||||
# session.save!
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
# UserMailer.deliveries.length.should == 1
|
||||
# calls[:count].should == 1
|
||||
# end
|
||||
|
||||
# it "does not send email when user is offline and opts out of emails" do
|
||||
# session.creator = sender
|
||||
# session.save!
|
||||
|
||||
# receiver.subscribe_email = false
|
||||
# receiver.save!
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
# UserMailer.deliveries.length.should == 0
|
||||
# calls[:count].should == 1
|
||||
# end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_cancelled(nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if there are no rsvp requests" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rescheduled" do
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
# it "sends email when user is offline and subscribes to emails" do
|
||||
# session.creator = sender
|
||||
# session.save!
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
# UserMailer.deliveries.length.should == 1
|
||||
# calls[:count].should == 1
|
||||
# end
|
||||
|
||||
# it "does not send email when user is offline and opts out of emails" do
|
||||
# session.creator = sender
|
||||
# session.save!
|
||||
|
||||
# receiver.subscribe_email = false
|
||||
# receiver.save!
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
# UserMailer.deliveries.length.should == 0
|
||||
# calls[:count].should == 1
|
||||
# end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rescheduled(nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if there are no rsvp requests" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rescheduled(session)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session reminder" do
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
# it "sends email when user is offline and subscribes to emails" do
|
||||
# session.creator = sender
|
||||
# session.save!
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
# UserMailer.deliveries.length.should == 1
|
||||
# calls[:count].should == 1
|
||||
# end
|
||||
|
||||
# it "does not send email when user is offline and opts out of emails" do
|
||||
# session.creator = sender
|
||||
# session.save!
|
||||
|
||||
# receiver.subscribe_email = false
|
||||
# receiver.save!
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
# UserMailer.deliveries.length.should == 0
|
||||
# calls[:count].should == 1
|
||||
# end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_reminder(nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if there are no rsvp requests" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_reminder(session)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session comment" do
|
||||
let(:receiver) {FactoryGirl.create(:user)}
|
||||
let(:sender) {FactoryGirl.create(:user)}
|
||||
let(:session) {FactoryGirl.create(:music_session)}
|
||||
|
||||
# it "sends email when user is offline and subscribes to emails" do
|
||||
# session.creator = sender
|
||||
# session.save!
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
# UserMailer.deliveries.length.should == 1
|
||||
# calls[:count].should == 1
|
||||
# end
|
||||
|
||||
# it "does not send email when user is offline and opts out of emails" do
|
||||
# session.creator = sender
|
||||
# session.save!
|
||||
|
||||
# receiver.subscribe_email = false
|
||||
# receiver.save!
|
||||
|
||||
# calls = count_publish_to_user_calls
|
||||
# notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
# UserMailer.deliveries.length.should == 0
|
||||
# calls[:count].should == 1
|
||||
# end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_comment(nil, sender, 'when are we playing?')
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_comment(session, nil, 'test')
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if comment is empty" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_comment(session, sender, '')
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send_text_message" do
|
||||
it "success when offline" do
|
||||
receiver = FactoryGirl.create(:user)
|
||||
|
|
@ -133,244 +760,4 @@ describe Notification do
|
|||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session invitation" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
sender = FactoryGirl.create(:user)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_invitation(nil, sender)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_invitation(session, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rsvp" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
sender = FactoryGirl.create(:user)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp(nil, sender, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp(session, nil, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rsvp approved" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
receiver = FactoryGirl.create(:user)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_approved(nil, receiver, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_approved(session, nil, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rsvp cancellation" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification" do
|
||||
end
|
||||
it "sends no notification if session is nil" do
|
||||
sender = FactoryGirl.create(:user)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled(nil, sender)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled(session, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rsvp cancellation by organizer" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
receiver = FactoryGirl.create(:user)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled_org(nil, receiver)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rsvp_cancelled_org(session, nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session cancellation" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_cancelled(nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if there are no rsvp requests" do
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_cancelled(session)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session rescheduled" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rescheduled(nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if there are no rsvp requests" do
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_rescheduled(session)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session reminder" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_reminder(nil)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if there are no rsvp requests" do
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_reminder(session)
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
|
||||
describe "send scheduled session comment" do
|
||||
it "sends pop-up notification" do
|
||||
end
|
||||
|
||||
it "sends email notification" do
|
||||
end
|
||||
|
||||
it "sends no notification if session is nil" do
|
||||
sender = FactoryGirl.create(:user)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_comment(nil, sender, 'when are we playing?')
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if user is nil" do
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_comment(session, nil, 'test')
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
|
||||
it "sends no notification if comment is empty" do
|
||||
sender = FactoryGirl.create(:user)
|
||||
session = FactoryGirl.create(:music_session)
|
||||
calls = count_publish_to_user_calls
|
||||
notification = Notification.send_scheduled_session_comment(session, sender, '')
|
||||
|
||||
UserMailer.deliveries.length.should == 0
|
||||
calls[:count].should == 0
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ describe "RenderMailers", :slow => true do
|
|||
let(:user2) { FactoryGirl.create(:user) }
|
||||
let(:friend_request) {FactoryGirl.create(:friend_request, user:user, friend: user2)}
|
||||
|
||||
it { @filename="text_message"; UserMailer.text_message(user.email, user2.id, user2.name, user2.resolved_photo_url, 'Get online!!').deliver }
|
||||
it { @filename="friend_request"; UserMailer.friend_request(user.email, 'So and so has sent you a friend request.', friend_request.id).deliver}
|
||||
it { @filename="text_message"; UserMailer.text_message(user, user2.id, user2.name, user2.resolved_photo_url, 'Get online!!').deliver }
|
||||
it { @filename="friend_request"; UserMailer.friend_request(user, 'So and so has sent you a friend request.', friend_request.id).deliver}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue