VRFS-1668 added some edge case tests for new notifications (still need sunny day tests)
This commit is contained in:
parent
0b2acda11e
commit
95100a1b49
|
|
@ -424,10 +424,11 @@ message ScheduledSessionComment {
|
|||
optional string session_id = 1;
|
||||
optional string photo_url = 2;
|
||||
optional string msg = 3;
|
||||
optional string session_name = 4;
|
||||
optional string session_date = 5;
|
||||
optional string notification_id = 6;
|
||||
optional string created_at = 7;
|
||||
optional string comment = 4;
|
||||
optional string session_name = 5;
|
||||
optional string session_date = 6;
|
||||
optional string notification_id = 7;
|
||||
optional string created_at = 8;
|
||||
}
|
||||
|
||||
message MusicianRecordingSaved {
|
||||
|
|
|
|||
|
|
@ -577,6 +577,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
def send_scheduled_session_invitation(music_session, user)
|
||||
|
||||
return if music_session.nil? || user.nil?
|
||||
|
||||
target_user = user
|
||||
source_user = music_session.creator
|
||||
|
||||
|
|
@ -612,6 +615,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
def send_scheduled_session_rsvp(music_session, user, instruments)
|
||||
|
||||
return if music_session.nil? || user.nil?
|
||||
|
||||
target_user = music_session.creator
|
||||
source_user = user
|
||||
|
||||
|
|
@ -649,6 +655,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
def send_scheduled_session_rsvp_approved(music_session, user)
|
||||
|
||||
return if music_session.nil? || user.nil?
|
||||
|
||||
target_user = user
|
||||
source_user = music_session.creator
|
||||
|
||||
|
|
@ -683,6 +692,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
def send_scheduled_session_rsvp_cancelled(music_session, user)
|
||||
|
||||
return if music_session.nil? || user.nil?
|
||||
|
||||
target_user = music_session.creator
|
||||
source_user = user
|
||||
|
||||
|
|
@ -717,6 +729,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
def send_scheduled_session_rsvp_cancelled_org(music_session, user)
|
||||
|
||||
return if music_session.nil? || user.nil?
|
||||
|
||||
target_user = user
|
||||
source_user = music_session.creator
|
||||
|
||||
|
|
@ -751,6 +766,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
def send_scheduled_session_cancelled(music_session)
|
||||
|
||||
return if music_session.nil?
|
||||
|
||||
rsvp_requests = RsvpRequest.requests_by_session(music_session)
|
||||
|
||||
rsvp_requests.each do |rsvp|
|
||||
|
|
@ -789,6 +807,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
def send_scheduled_session_rescheduled(music_session)
|
||||
|
||||
return if music_session.nil?
|
||||
|
||||
rsvp_requests = RsvpRequest.requests_by_session(music_session)
|
||||
|
||||
rsvp_requests.each do |rsvp|
|
||||
|
|
@ -827,6 +848,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
def send_scheduled_session_reminder(music_session)
|
||||
|
||||
return if music_session.nil?
|
||||
|
||||
rsvp_requests = RsvpRequest.requests_by_session(music_session)
|
||||
|
||||
rsvp_requests.each do |rsvp|
|
||||
|
|
@ -865,6 +889,9 @@ module JamRuby
|
|||
end
|
||||
|
||||
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.each do |rsvp|
|
||||
|
|
|
|||
|
|
@ -13,18 +13,18 @@ module JamRuby
|
|||
query = RsvpRequest
|
||||
.includes(:user)
|
||||
.joins(
|
||||
%Q{
|
||||
INNER join
|
||||
rsvp_slots rs
|
||||
ON
|
||||
rsvp_requests.rsvp_slot_id = rs.id
|
||||
}
|
||||
)
|
||||
.where(
|
||||
%Q{
|
||||
rsvp_slots.music_session_id = '#{session.id}''
|
||||
}
|
||||
)
|
||||
%Q{
|
||||
INNER join
|
||||
rsvp_slots rs
|
||||
ON
|
||||
rsvp_requests.rsvp_slot_id = rs.id
|
||||
}
|
||||
)
|
||||
.where(
|
||||
%Q{
|
||||
rs.music_session_id = '#{session.id}'
|
||||
}
|
||||
)
|
||||
|
||||
query = query.where("rsvp_requests.user_id = '#{user.id}'") unless user.nil?
|
||||
return query
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ describe Notification do
|
|||
|
||||
before(:each) do
|
||||
UserMailer.deliveries.clear
|
||||
|
||||
end
|
||||
|
||||
def count_publish_to_user_calls
|
||||
|
|
@ -134,4 +133,234 @@ describe Notification do
|
|||
calls[:count].should == 0
|
||||
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
|
||||
|
|
|
|||
Loading…
Reference in New Issue