new user match email - jamkazam team only
add a config to restrict new_musicians_match email to be sent only to jamkazam team users
This commit is contained in:
parent
371f68a616
commit
051477d19f
|
|
@ -33,7 +33,6 @@ module JamRuby
|
|||
end
|
||||
|
||||
begin
|
||||
|
||||
recipients = User.where("users.subscribe_email = ? AND
|
||||
users.subscribe_email_for_user_match = ?
|
||||
AND NOT COALESCE(users.user_match_email_sent_at, ?) > ?",
|
||||
|
|
@ -41,12 +40,17 @@ module JamRuby
|
|||
CASE WHEN users.email IN ('#{PRIORITY_RECIPIENTS.map {|str| "\"#{str}\""}.join(',')}')
|
||||
THEN 0 ELSE 1 END, last_active_at DESC").select("users.*,
|
||||
GREATEST(updated_at, last_jam_updated_at) AS last_active_at").limit(LIMIT)
|
||||
|
||||
# If the flag is set to send user match email only to jamkazam team
|
||||
if Rails.application.config.send_user_match_mail_only_to_jamkazam_team
|
||||
recipients = recipients.where(email: PRIORITY_RECIPIENTS)
|
||||
end
|
||||
|
||||
AdminMailer.ugly({to: APP_CONFIG.user_match_monitoring_email,
|
||||
subject:"Weekly user match email sending job started.",
|
||||
body: "#{email_sending.sent_user_ids.any?? "This job is resuming. It was originally started at #{email_sending.created_at} and has been sent to #{email_sending.sent_user_ids.size} user(s) so far." : "This job was started at #{email_sending.created_at}" }. It will send to total of #{ recipients.size } users."}).deliver_now
|
||||
|
||||
recipients.find_each do |user|
|
||||
recipients.find_each do |user|
|
||||
|
||||
ip_address = user.last_jam_addr.blank?? '127.0.0.1' : IPAddr.new(user.last_jam_addr, Socket::AF_INET).to_s
|
||||
matched_musician_data = []
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ describe EmailNewMusicianMatch do
|
|||
ActionMailer::Base.deliveries = []
|
||||
User.delete_all
|
||||
allow(JamRuby::MusicianFilter).to receive(:filter).and_return(search_result)
|
||||
Rails.application.config.send_user_match_mail_only_to_jamkazam_team = false
|
||||
end
|
||||
|
||||
after(:each) do
|
||||
|
|
@ -46,6 +47,14 @@ describe EmailNewMusicianMatch do
|
|||
JamRuby::EmailNewMusicianMatch.send_new_musicians
|
||||
end
|
||||
|
||||
it "delivers only to priority recipients" do
|
||||
Rails.application.config.send_user_match_mail_only_to_jamkazam_team = true
|
||||
allow(UserMailer).to receive(:new_musicians_match).and_return(mail)
|
||||
expect(mail).to receive(:deliver_now).exactly(1).times #only to the priority user seth@jamkazam
|
||||
JamRuby::EmailNewMusicianMatch.send_new_musicians
|
||||
end
|
||||
|
||||
|
||||
xit "delivers to priority recipients first" do
|
||||
JamRuby::EmailNewMusicianMatch.send_new_musicians
|
||||
raise ActionMailer::Base.deliveries.map{|d| d['to'].to_s }.inspect #.include?("seth@example.com").should be_truthy
|
||||
|
|
|
|||
|
|
@ -518,5 +518,6 @@ if defined?(Bundler)
|
|||
config.manual_override_installer_ends_with = "JamKazam-1.0.3776.dmg"
|
||||
config.spa_origin = "http://beta.jamkazam.local:4000"
|
||||
config.user_match_monitoring_email = "user_match_monitoring_email@jamkazam.com"
|
||||
config.send_user_match_mail_only_to_jamkazam_team = true
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -125,4 +125,6 @@ SampleApp::Application.configure do
|
|||
|
||||
config.action_controller.asset_host = 'http://localhost:3000'
|
||||
config.action_mailer.asset_host = config.action_controller.asset_host
|
||||
|
||||
config.send_user_match_mail_only_to_jamkazam_team = false
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in New Issue