Commit 833c3aafa9a19bf3bdfecfad97e6bb4a883fe56f

Authored by Dhruv Kapadia
1 parent 24539bcc

Adding sendgrid support to pairwise

app/models/cron_mailer.rb
  1 +unless Rails.env == "development"
  2 + include SendGrid
  3 +end
1 4 class CronMailer < ActionMailer::Base
2 5  
3 6 def info_message(recipients, subject, message, sent_at= Time.now)
... ... @@ -8,8 +11,4 @@ class CronMailer &lt; ActionMailer::Base
8 11 @body[:message] = message
9 12 @body[:host] = "www.allourideas.org"
10 13 end
11   -
12   -
13   -
14   -
15 14 end
... ...
config/environment.rb
... ... @@ -53,5 +53,7 @@ Rails::Initializer.run do |config|
53 53 :version => '2.0.3'
54 54 config.gem 'redis',
55 55 :version => '1.0.7'
  56 +
  57 + config.gem 'sendgrid'
56 58 end
57 59  
... ...
config/initializers/mail.rb
... ... @@ -3,14 +3,13 @@
3 3  
4 4 # heroku config:add GMAIL_EMAIL=dcroak@example.com GMAIL_PASSWORD=password
5 5  
6   -require 'smtp-tls'
7   -
8 6 ActionMailer::Base.smtp_settings = {
9   - :address => "smtp.gmail.com",
10   - :port => "587",
  7 + :address => "smtp.sendgrid.net",
  8 + :port => "25",
11 9 :authentication => :plain,
12   - :user_name => ENV['GMAIL_EMAIL'],
13   - :password => ENV['GMAIL_PASSWORD']
  10 + :domain => "allourideas.org",
  11 + :user_name => ENV['SENDGRID_USERNAME'],
  12 + :password => ENV['SENDGRID_PASSWORD']
14 13 }
15 14  
16 15 DO_NOT_REPLY = "donotreply@example.com"
... ...
lib/tasks/test_api.rake
... ... @@ -375,7 +375,7 @@ namespace :test_api do
375 375 delta = 0.001
376 376  
377 377 if (cached_score - generated_score).abs >= delta
378   - error_message += "Error! The cached_score is not equal to the calculated score for choice #{choice.id}"
  378 + error_message += "Error! The cached_score is not equal to the calculated score for choice #{choice.id}\n"
379 379  
380 380 print "This score is wrong! #{choice.id} , Question ID: #{question.id}, #{cached_score}, #{generated_score}, updated: #{choice.updated_at}\n"
381 381  
... ...