VRFS-2140 added more tests, fixed bug found in recording notification

This commit is contained in:
Brian Smith 2014-09-11 08:38:26 -04:00
parent a7623aac26
commit 0b1f9d0c97
2 changed files with 30 additions and 3 deletions

View File

@ -1021,7 +1021,7 @@ module JamRuby
user_followers = user.followers
# construct an array of User objects representing friends and followers
friend_users = friends.map { |fu| fu.friend }
friend_users = friends.map { |fu| fu.user }
follower_users = user_followers.map { |uf| uf.user }
friends_and_followers = friend_users.concat(follower_users).uniq
@ -1232,7 +1232,7 @@ module JamRuby
begin
UserMailer.band_invitation(receiver, notification_msg).deliver
rescue => e
@@log.error("Unable to send band_invitation email to offline user #{receiver.email} #{e}")
@@log.error("Unable to send BAND_INVITATION email to offline user #{receiver.email} #{e}")
end
end
end
@ -1263,7 +1263,7 @@ module JamRuby
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}")
@@log.error("Unable to send BAND_INVITATION_ACCEPTED email to offline user #{receiver.email} #{e}")
end
end
end

View File

@ -227,6 +227,33 @@ describe Notification do
end
describe "send musician recording saved join" do
let(:receiver) {FactoryGirl.create(:user)}
let(:recording) {FactoryGirl.create(:recording)}
# it "sends email when user is offline and subscribes to emails" do
# FactoryGirl.create(:friendship, :user => receiver, :friend => recording.owner)
# FactoryGirl.create(:friendship, :user => recording.owner, :friend => receiver)
# calls = count_publish_to_user_calls
# Notification.send_musician_recording_saved(recording)
# 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
FactoryGirl.create(:friendship, :user => receiver, :friend => recording.owner)
FactoryGirl.create(:friendship, :user => recording.owner, :friend => receiver)
receiver.subscribe_email = false
receiver.save!
calls = count_publish_to_user_calls
Notification.send_musician_recording_saved(recording)
UserMailer.deliveries.length.should == 0
calls[:count].should == 0
end
end
describe "send band recording saved join" do