diff --git a/ruby/lib/jam_ruby/models/notification.rb b/ruby/lib/jam_ruby/models/notification.rb index 553ab1acc..fa9c8c6b1 100644 --- a/ruby/lib/jam_ruby/models/notification.rb +++ b/ruby/lib/jam_ruby/models/notification.rb @@ -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 diff --git a/ruby/spec/jam_ruby/models/notification_spec.rb b/ruby/spec/jam_ruby/models/notification_spec.rb index 8d0fc2a85..95e425938 100644 --- a/ruby/spec/jam_ruby/models/notification_spec.rb +++ b/ruby/spec/jam_ruby/models/notification_spec.rb @@ -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