VRFS-1668 added some edge case tests for new notifications (still need sunny day tests)

This commit is contained in:
Brian Smith 2014-05-18 14:59:57 -04:00
parent 0b2acda11e
commit 95100a1b49
4 changed files with 274 additions and 17 deletions

View File

@ -424,10 +424,11 @@ message ScheduledSessionComment {
optional string session_id = 1; optional string session_id = 1;
optional string photo_url = 2; optional string photo_url = 2;
optional string msg = 3; optional string msg = 3;
optional string session_name = 4; optional string comment = 4;
optional string session_date = 5; optional string session_name = 5;
optional string notification_id = 6; optional string session_date = 6;
optional string created_at = 7; optional string notification_id = 7;
optional string created_at = 8;
} }
message MusicianRecordingSaved { message MusicianRecordingSaved {

View File

@ -577,6 +577,9 @@ module JamRuby
end end
def send_scheduled_session_invitation(music_session, user) def send_scheduled_session_invitation(music_session, user)
return if music_session.nil? || user.nil?
target_user = user target_user = user
source_user = music_session.creator source_user = music_session.creator
@ -612,6 +615,9 @@ module JamRuby
end end
def send_scheduled_session_rsvp(music_session, user, instruments) def send_scheduled_session_rsvp(music_session, user, instruments)
return if music_session.nil? || user.nil?
target_user = music_session.creator target_user = music_session.creator
source_user = user source_user = user
@ -649,6 +655,9 @@ module JamRuby
end end
def send_scheduled_session_rsvp_approved(music_session, user) def send_scheduled_session_rsvp_approved(music_session, user)
return if music_session.nil? || user.nil?
target_user = user target_user = user
source_user = music_session.creator source_user = music_session.creator
@ -683,6 +692,9 @@ module JamRuby
end end
def send_scheduled_session_rsvp_cancelled(music_session, user) def send_scheduled_session_rsvp_cancelled(music_session, user)
return if music_session.nil? || user.nil?
target_user = music_session.creator target_user = music_session.creator
source_user = user source_user = user
@ -717,6 +729,9 @@ module JamRuby
end end
def send_scheduled_session_rsvp_cancelled_org(music_session, user) def send_scheduled_session_rsvp_cancelled_org(music_session, user)
return if music_session.nil? || user.nil?
target_user = user target_user = user
source_user = music_session.creator source_user = music_session.creator
@ -751,6 +766,9 @@ module JamRuby
end end
def send_scheduled_session_cancelled(music_session) def send_scheduled_session_cancelled(music_session)
return if music_session.nil?
rsvp_requests = RsvpRequest.requests_by_session(music_session) rsvp_requests = RsvpRequest.requests_by_session(music_session)
rsvp_requests.each do |rsvp| rsvp_requests.each do |rsvp|
@ -789,6 +807,9 @@ module JamRuby
end end
def send_scheduled_session_rescheduled(music_session) def send_scheduled_session_rescheduled(music_session)
return if music_session.nil?
rsvp_requests = RsvpRequest.requests_by_session(music_session) rsvp_requests = RsvpRequest.requests_by_session(music_session)
rsvp_requests.each do |rsvp| rsvp_requests.each do |rsvp|
@ -827,6 +848,9 @@ module JamRuby
end end
def send_scheduled_session_reminder(music_session) def send_scheduled_session_reminder(music_session)
return if music_session.nil?
rsvp_requests = RsvpRequest.requests_by_session(music_session) rsvp_requests = RsvpRequest.requests_by_session(music_session)
rsvp_requests.each do |rsvp| rsvp_requests.each do |rsvp|
@ -865,6 +889,9 @@ module JamRuby
end end
def send_scheduled_session_comment(music_session, comment) def send_scheduled_session_comment(music_session, comment)
return if music_session.nil? || comment.blank?
rsvp_requests = RsvpRequest.requests_by_session(music_session) rsvp_requests = RsvpRequest.requests_by_session(music_session)
rsvp_requests.each do |rsvp| rsvp_requests.each do |rsvp|

View File

@ -13,18 +13,18 @@ module JamRuby
query = RsvpRequest query = RsvpRequest
.includes(:user) .includes(:user)
.joins( .joins(
%Q{ %Q{
INNER join INNER join
rsvp_slots rs rsvp_slots rs
ON ON
rsvp_requests.rsvp_slot_id = rs.id rsvp_requests.rsvp_slot_id = rs.id
} }
) )
.where( .where(
%Q{ %Q{
rsvp_slots.music_session_id = '#{session.id}'' rs.music_session_id = '#{session.id}'
} }
) )
query = query.where("rsvp_requests.user_id = '#{user.id}'") unless user.nil? query = query.where("rsvp_requests.user_id = '#{user.id}'") unless user.nil?
return query return query

View File

@ -4,7 +4,6 @@ describe Notification do
before(:each) do before(:each) do
UserMailer.deliveries.clear UserMailer.deliveries.clear
end end
def count_publish_to_user_calls def count_publish_to_user_calls
@ -134,4 +133,234 @@ describe Notification do
calls[:count].should == 0 calls[:count].should == 0
end end
end end
describe "send scheduled session invitation" do
it "sends live notification when user is online" do
end
it "sends email notification when user is offline" 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 live notification when user is online" do
end
it "sends email notification when user is offline" 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 live notification when user is online" do
end
it "sends email notification when user is offline" 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)
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)
UserMailer.deliveries.length.should == 0
calls[:count].should == 0
end
end
describe "send scheduled session rsvp cancellation" do
it "sends live notification when user is online" do
end
it "sends email notification when user is offline" 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 live notification when user is online" do
end
it "sends email notification when user is offline" 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 live notification when user is online" do
end
it "sends email notification when user is offline" 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 live notification when user is online" do
end
it "sends email notification when user is offline" 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 live notification when user is online" do
end
it "sends email notification when user is offline" 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 live notification when user is online" do
end
it "sends email notification when user is offline" do
end
it "sends no notification if session is nil" do
calls = count_publish_to_user_calls
notification = Notification.send_scheduled_session_comment(nil, 'when are we playing?')
UserMailer.deliveries.length.should == 0
calls[:count].should == 0
end
it "sends no notification if comment is empty" do
session = FactoryGirl.create(:music_session)
calls = count_publish_to_user_calls
notification = Notification.send_scheduled_session_comment(nil, session)
UserMailer.deliveries.length.should == 0
calls[:count].should == 0
end
end
end end