mail_spy 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (83) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.rdoc +68 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/mail_spy/application.js +15 -0
  5. data/app/assets/javascripts/mail_spy/tracking.js +2 -0
  6. data/app/assets/stylesheets/mail_spy/application.css +13 -0
  7. data/app/assets/stylesheets/mail_spy/tracking.css +4 -0
  8. data/app/controllers/mail_spy/application_controller.rb +4 -0
  9. data/app/controllers/mail_spy/tracking_controller.rb +53 -0
  10. data/app/helpers/mail_spy/application_helper.rb +4 -0
  11. data/app/helpers/mail_spy/email_helper.rb +40 -0
  12. data/app/mailers/mail_spy/core_mailer.rb +55 -0
  13. data/app/models/mail_spy/action.rb +23 -0
  14. data/app/models/mail_spy/campaign_report.rb +6 -0
  15. data/app/models/mail_spy/component_report.rb +6 -0
  16. data/app/models/mail_spy/email.rb +93 -0
  17. data/app/models/mail_spy/email_template.rb +17 -0
  18. data/app/models/mail_spy/stream_report.rb +6 -0
  19. data/app/views/layouts/mail_spy/application.html.erb +14 -0
  20. data/config/routes.rb +7 -0
  21. data/lib/generators/mail_spy/initialize_generator.rb +12 -0
  22. data/lib/generators/mail_spy/templates/mail_spy.rb +25 -0
  23. data/lib/mail_spy/engine.rb +13 -0
  24. data/lib/mail_spy/manager.rb +97 -0
  25. data/lib/mail_spy/version.rb +3 -0
  26. data/lib/mail_spy.rb +36 -0
  27. data/lib/tasks/mail_spy_tasks.rake +40 -0
  28. data/test/dummy/README.rdoc +261 -0
  29. data/test/dummy/Rakefile +7 -0
  30. data/test/dummy/app/assets/javascripts/application.js +15 -0
  31. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  32. data/test/dummy/app/controllers/application_controller.rb +3 -0
  33. data/test/dummy/app/helpers/application_helper.rb +2 -0
  34. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  35. data/test/dummy/config/application.rb +56 -0
  36. data/test/dummy/config/boot.rb +10 -0
  37. data/test/dummy/config/database.yml +25 -0
  38. data/test/dummy/config/environment.rb +5 -0
  39. data/test/dummy/config/environments/development.rb +37 -0
  40. data/test/dummy/config/environments/production.rb +67 -0
  41. data/test/dummy/config/environments/test.rb +37 -0
  42. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  43. data/test/dummy/config/initializers/inflections.rb +15 -0
  44. data/test/dummy/config/initializers/mime_types.rb +5 -0
  45. data/test/dummy/config/initializers/secret_token.rb +7 -0
  46. data/test/dummy/config/initializers/session_store.rb +8 -0
  47. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  48. data/test/dummy/config/locales/en.yml +5 -0
  49. data/test/dummy/config/mongoid.yml +20 -0
  50. data/test/dummy/config/routes.rb +4 -0
  51. data/test/dummy/config.ru +4 -0
  52. data/test/dummy/db/development.sqlite3 +0 -0
  53. data/test/dummy/db/seeds.rb +16 -0
  54. data/test/dummy/db/test.sqlite3 +0 -0
  55. data/test/dummy/log/development.log +212 -0
  56. data/test/dummy/log/test.log +6841 -0
  57. data/test/dummy/public/404.html +26 -0
  58. data/test/dummy/public/422.html +26 -0
  59. data/test/dummy/public/500.html +25 -0
  60. data/test/dummy/public/favicon.ico +0 -0
  61. data/test/dummy/script/rails +6 -0
  62. data/test/fixtures/mail_spy/actions.yml +7 -0
  63. data/test/fixtures/mail_spy/campaign_reports.yml +11 -0
  64. data/test/fixtures/mail_spy/component_reports.yml +11 -0
  65. data/test/fixtures/mail_spy/email_templates.yml +9 -0
  66. data/test/fixtures/mail_spy/emails.yml +15 -0
  67. data/test/fixtures/mail_spy/stream_reports.yml +11 -0
  68. data/test/functional/mail_spy/core_mailer_test.rb +33 -0
  69. data/test/functional/mail_spy/tracking_controller_test.rb +83 -0
  70. data/test/integration/navigation_test.rb +10 -0
  71. data/test/mail_spy_test.rb +7 -0
  72. data/test/test_email_credentials.yml +9 -0
  73. data/test/test_email_credentials.yml.sample +9 -0
  74. data/test/test_helper.rb +107 -0
  75. data/test/unit/helpers/mail_spy/tracking_helper_test.rb +6 -0
  76. data/test/unit/mail_spy/action_test.rb +9 -0
  77. data/test/unit/mail_spy/campaign_report_test.rb +9 -0
  78. data/test/unit/mail_spy/component_report_test.rb +9 -0
  79. data/test/unit/mail_spy/email_template_test.rb +9 -0
  80. data/test/unit/mail_spy/email_test.rb +9 -0
  81. data/test/unit/mail_spy/manager_test.rb +164 -0
  82. data/test/unit/mail_spy/stream_report_test.rb +9 -0
  83. metadata +343 -0
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The page you were looking for doesn't exist (404)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/404.html -->
21
+ <div class="dialog">
22
+ <h1>The page you were looking for doesn't exist.</h1>
23
+ <p>You may have mistyped the address or the page may have moved.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,26 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>The change you wanted was rejected (422)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/422.html -->
21
+ <div class="dialog">
22
+ <h1>The change you wanted was rejected.</h1>
23
+ <p>Maybe you tried to change something you didn't have access to.</p>
24
+ </div>
25
+ </body>
26
+ </html>
@@ -0,0 +1,25 @@
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <title>We're sorry, but something went wrong (500)</title>
5
+ <style type="text/css">
6
+ body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
7
+ div.dialog {
8
+ width: 25em;
9
+ padding: 0 4em;
10
+ margin: 4em auto 0 auto;
11
+ border: 1px solid #ccc;
12
+ border-right-color: #999;
13
+ border-bottom-color: #999;
14
+ }
15
+ h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
16
+ </style>
17
+ </head>
18
+
19
+ <body>
20
+ <!-- This file lives in public/500.html -->
21
+ <div class="dialog">
22
+ <h1>We're sorry, but something went wrong.</h1>
23
+ </div>
24
+ </body>
25
+ </html>
File without changes
@@ -0,0 +1,6 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application.
3
+
4
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
5
+ require File.expand_path('../../config/boot', __FILE__)
6
+ require 'rails/commands'
@@ -0,0 +1,7 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ action_type: MyString
5
+
6
+ two:
7
+ action_type: MyString
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,9 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ html_erb: MyText
5
+ options:
6
+
7
+ two:
8
+ html_erb: MyText
9
+ options:
@@ -0,0 +1,15 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ one:
4
+ email_address: MyString
5
+ user_id: 1
6
+ campaign: MyString
7
+ stream: MyString
8
+ component: MyString
9
+
10
+ two:
11
+ email_address: MyString
12
+ user_id: 1
13
+ campaign: MyString
14
+ stream: MyString
15
+ component: MyString
@@ -0,0 +1,11 @@
1
+ # Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
2
+
3
+ # This model initially had no columns defined. If you add columns to the
4
+ # model remove the '{}' from the fixture names and add the columns immediately
5
+ # below each fixture, per the syntax in the comments below
6
+ #
7
+ one: {}
8
+ # column: value
9
+ #
10
+ two: {}
11
+ # column: value
@@ -0,0 +1,33 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class CoreMailerTest < ActionMailer::TestCase
5
+
6
+ def teardown
7
+ MailSpy::EmailTemplate.delete_all
8
+ MailSpy::Email.delete_all
9
+ end
10
+
11
+ test "the truth" do
12
+ assert true
13
+ end
14
+
15
+ def test_template_email_helpers
16
+ initialize_mail_spy_test_esp
17
+
18
+ html_erb = "A link : <%= track_link 'My home', 'www.google.com' %> <br> A Bug <%= tracking_bug %>"
19
+ text_erb = "A link : <%= track_link 'My home', 'www.google.com' %> <br> A Bug <%= tracking_bug %>"
20
+ template_values_definition = {}
21
+
22
+ template = MailSpy.add_template("a test template", html_erb, text_erb, template_values_definition)
23
+ create_emails(template)
24
+ email = MailSpy::Email.first
25
+ mail = MailSpy::CoreMailer.template(email)
26
+
27
+ assert(mail.present?, "Mail should render without error")
28
+ assert(mail.html_part.body.present?, "Mail should have a html part")
29
+ assert(mail.text_part.body.present?, "Mail should have a text part")
30
+ end
31
+
32
+ end
33
+ end
@@ -0,0 +1,83 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class TrackingControllerTest < ActionController::TestCase
5
+
6
+ def setup
7
+ initialize_mail_spy_test_esp
8
+
9
+ html_erb = "A link : <%= track_link 'My home', 'www.google.com' %> <br> A Bug <%= tracking_bug %>"
10
+ text_erb = "A link : <%= track_link 'My home', 'www.google.com' %> <br> A Bug <%= tracking_bug %>"
11
+ template_values_definition = {}
12
+
13
+ template = MailSpy.add_template("a test template", html_erb, text_erb, template_values_definition)
14
+ create_emails(template)
15
+ @email = MailSpy::Email.first
16
+ end
17
+
18
+ def teardown
19
+ MailSpy::EmailTemplate.delete_all
20
+ MailSpy::Email.delete_all
21
+ end
22
+
23
+ test "the truth" do
24
+ assert true
25
+ end
26
+
27
+ def test_link_tracking
28
+ params = {
29
+ :eid => @email.id,
30
+ :url =>"http://google.com",
31
+ :n => 0
32
+ }
33
+
34
+ get "link", params
35
+
36
+ assert_redirected_to params[:url]
37
+
38
+ email = @email.reload
39
+ details = email.actions.first.details
40
+
41
+ assert(email.actions.length == 1, "The email should only have on action at this point")
42
+ assert(email.actions.first.action_type == MailSpy::Action::ACTION_TYPE_CLICK,"Action type should be click")
43
+ assert(details[:url] == params[:url], "Url should be recorded")
44
+ assert(details[:link_number].to_i == params[:n].to_i, "link number should be recorded")
45
+ assert(email.actions.first.count == 1, "the action count should be 1")
46
+ end
47
+
48
+
49
+ def test_bug_tracking
50
+ params = {
51
+ :eid => @email.id,
52
+ }
53
+
54
+ get "bug", params
55
+
56
+ assert_response :success
57
+ email = @email.reload
58
+ assert(email.actions.length == 1, "The email should only have on action at this point")
59
+ assert(email.actions.first.action_type == MailSpy::Action::ACTION_TYPE_OPEN,"Action type should be open")
60
+ assert(email.actions.first.count == 1, "the action count should be 1")
61
+
62
+ end
63
+
64
+ def test_action_tracking
65
+ params = {
66
+ :eid => @email.id,
67
+ :action_type => "Conversion",
68
+ :count => 3
69
+ }
70
+
71
+ get "action", params
72
+
73
+ assert_response :success
74
+ email = @email.reload
75
+ assert(email.actions.length == 1, "The email should only have on action at this point")
76
+ assert(email.actions.first.action_type == params[:action_type],"Action type should be conversion")
77
+ assert(email.actions.first.count == params[:count], "the action count should be 1")
78
+
79
+ end
80
+
81
+
82
+ end
83
+ end
@@ -0,0 +1,10 @@
1
+ require 'test_helper'
2
+
3
+ class NavigationTest < ActionDispatch::IntegrationTest
4
+ fixtures :all
5
+
6
+ # test "the truth" do
7
+ # assert true
8
+ # end
9
+ end
10
+
@@ -0,0 +1,7 @@
1
+ require 'test_helper'
2
+
3
+ class MailSpyTest < ActiveSupport::TestCase
4
+ test "truth" do
5
+ assert_kind_of Module, MailSpy
6
+ end
7
+ end
@@ -0,0 +1,9 @@
1
+ name: sendgrid
2
+ address: smtp.sendgrid.net
3
+ port: 587
4
+ domain: herokuapp.com
5
+ user_name: app2546146@heroku.com
6
+ password: g4eiapwq
7
+ authentication: plain
8
+ enable_starttls_auto: 1
9
+ test_email_address: trcarden@gmail.com
@@ -0,0 +1,9 @@
1
+ name: sendgrid
2
+ address: smtp.sendgrid.net
3
+ port: 587
4
+ domain: herokuapp.com
5
+ user_name: username
6
+ password: pass
7
+ authentication: plain
8
+ enable_starttls_auto: 1
9
+ test_email_address: test@test.com
@@ -0,0 +1,107 @@
1
+ require 'spork'
2
+ require 'yaml'
3
+
4
+ Spork.prefork do
5
+ # Loading more in this block will cause your tests to run faster. However,
6
+ # if you change any configuration or code from libraries loaded here, you'll
7
+ # need to restart spork for it take effect.
8
+
9
+ # Configure Rails Environment
10
+ ENV["RAILS_ENV"] = "test"
11
+
12
+ require "rails/mongoid"
13
+ Spork.trap_class_method(Rails::Mongoid, :load_models)
14
+
15
+
16
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
17
+ require "rails/test_help"
18
+
19
+ Rails.backtrace_cleaner.remove_silencers!
20
+
21
+ # Load support files
22
+ Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
23
+
24
+ #Turn output for tests
25
+ begin
26
+ require 'turn'
27
+ rescue LoadError
28
+ end
29
+
30
+ end
31
+
32
+ class ActiveSupport::TestCase
33
+ # Add more helper methods to be used by all tests here...
34
+
35
+
36
+
37
+ # Adds the ESP settings for a test email
38
+ def initialize_mail_spy_test_esp
39
+ path = File.expand_path ".././test_email_credentials.yml", __FILE__
40
+ credentials = YAML.load(File.open(path)).to_options
41
+ MailSpy.add_email_service_provider do |esp|
42
+ esp.name = credentials[:name]
43
+ esp.address = credentials[:address]
44
+ esp.port = credentials[:port]
45
+ esp.domain = credentials[:domain]
46
+ esp.user_name = credentials[:user_name]
47
+ esp.password = credentials[:password]
48
+ esp.authentication = credentials[:authentication]
49
+ esp.enable_starttls_auto = (credentials[:enable_starttls_auto].to_i == 1)
50
+ end
51
+ end
52
+
53
+ # Gets the test email address from the setup file
54
+ def email_address_for_test
55
+ path = File.expand_path ".././test_email_credentials.yml", __FILE__
56
+ credentials = YAML.load(File.open(path)).to_options
57
+ credentials[:test_email_address]
58
+ end
59
+
60
+ # Provides a template to operate on
61
+ def do_with_template(&block)
62
+ template_name = "test"
63
+ html_erb = "Hello World"
64
+ text_erb = "Hello World"
65
+ template_values_definition = {}
66
+
67
+ template = MailSpy.add_template(template_name, html_erb, text_erb, template_values_definition)
68
+ block.call(template)
69
+ end
70
+
71
+ # Creates a test email from a given template
72
+ def create_emails(template, num_emails=1)
73
+ num_emails.times do
74
+ to = email_address_for_test
75
+ from = "test@test.com"
76
+ reply_to = "testGuy"
77
+ subject = "test subject"
78
+ template_name = template.name
79
+ campaign = "test campaign"
80
+ stream = "test stream"
81
+ component = "test component"
82
+ schedule_at = DateTime.now
83
+
84
+ MailSpy.add_instance(
85
+ :to => to,
86
+ :from => from,
87
+ :reply_to => reply_to,
88
+ :subject => subject,
89
+ :template_name => template_name,
90
+ :template_values => {},
91
+ :campaign => campaign,
92
+ :stream => stream,
93
+ :component => component,
94
+ :schedule_at => schedule_at
95
+ )
96
+ end
97
+ end
98
+
99
+
100
+ # Setup all fixtures in test/fixtures/*.(yml|csv) for all tests in alphabetical order.
101
+ #
102
+ # Note: You'll currently still have to declare fixtures explicitly in integration tests
103
+ # -- they do not yet inherit this setting
104
+ #fixtures :all
105
+
106
+ #TestNotifier.default_notifier = :growl
107
+ end
@@ -0,0 +1,6 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class TrackingHelperTest < ActionView::TestCase
5
+ end
6
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class ActionTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class CampaignReportTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class ComponentReportTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class EmailTemplateTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class EmailTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end
@@ -0,0 +1,164 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class ManagerTest < ActiveSupport::TestCase
5
+ test "the truth" do
6
+ assert true
7
+ end
8
+
9
+ def setup
10
+ MailSpy::EmailTemplate.delete_all
11
+ MailSpy::Email.delete_all
12
+ end
13
+
14
+ # ------------------------------------------- ADD_TEMPLATE
15
+ def test_add_template
16
+ template_name = "test"
17
+ html_erb = "Hello World"
18
+ text_erb = "Hello World"
19
+ template_values_definition = {}
20
+
21
+ template = MailSpy.add_template(template_name, html_erb, text_erb, template_values_definition)
22
+
23
+ assert(template.html_erb == html_erb, "values should be written")
24
+ assert(template.text_erb == text_erb, "values should be written")
25
+ assert(template.template_values_definition == template_values_definition, "values should be written")
26
+ assert(template.name == template_name, "values should be written")
27
+ end
28
+
29
+ # ------------------------------------------- ADD_INSTANCE
30
+ def test_add_instance
31
+ do_with_template do |template|
32
+ to = "test@test.com"
33
+ from = "test@test.com"
34
+ reply_to = "testGuy"
35
+ subject = "test subject"
36
+ template_name = template.name
37
+ campaign = "test campaign"
38
+ stream = "test stream"
39
+ component = "test component"
40
+ schedule_at = DateTime.now
41
+
42
+ email = MailSpy.add_instance(
43
+ :to => to,
44
+ :from => from,
45
+ :reply_to => reply_to,
46
+ :subject => subject,
47
+ :template_name => template_name,
48
+ :template_values => {},
49
+ :campaign => campaign,
50
+ :stream => stream,
51
+ :component => component,
52
+ :schedule_at => schedule_at
53
+ )
54
+
55
+ assert(email.to == to, "email subject must be set")
56
+ assert(email.subject == subject, "email subject must be set")
57
+ assert(email.template_name == template_name, "email template_name must be set")
58
+ assert(email.campaign == campaign, "email campaign must be set")
59
+ assert(email.stream == stream, "email stream must be set")
60
+ assert(email.component == component, "email component must be set")
61
+ assert(email.schedule_at.to_i == schedule_at.to_i, "email schedule_at must be set")
62
+ end
63
+ end
64
+
65
+ def test_missing_sender
66
+ do_with_template do |template|
67
+ from = "test@test.com"
68
+ reply_to = "testGuy"
69
+ subject = "test subject"
70
+ template_name = template.name
71
+ campaign = "test campaign"
72
+ stream = "test stream"
73
+ component = "test component"
74
+ schedule_at = DateTime.now
75
+
76
+ assert_raise RuntimeError do
77
+ MailSpy.add_instance(
78
+ :from => from,
79
+ :reply_to => reply_to,
80
+ :subject => subject,
81
+ :template_name => template_name,
82
+ :template_values => {},
83
+ :campaign => campaign,
84
+ :stream => stream,
85
+ :component => component,
86
+ :schedule_at => schedule_at
87
+ )
88
+ end
89
+ end
90
+ end
91
+
92
+ def test_missing_required_field
93
+
94
+ do_with_template do |template|
95
+ to = "test@test.com"
96
+ from = "test@test.com"
97
+ reply_to = "testGuy"
98
+ template_name = template.name
99
+ campaign = "test campaign"
100
+ stream = "test stream"
101
+ component = "test component"
102
+ schedule_at = DateTime.now
103
+
104
+ assert_raise RuntimeError do
105
+ MailSpy.add_instance(
106
+ :to => to,
107
+ :from => from,
108
+ :reply_to => reply_to,
109
+ :template_name => template_name,
110
+ :template_values => {},
111
+ :campaign => campaign,
112
+ :stream => stream,
113
+ :component => component,
114
+ :schedule_at => schedule_at
115
+ )
116
+ end
117
+ end
118
+
119
+ end
120
+
121
+ def test_referencing_missing_template
122
+ do_with_template do |template|
123
+ to = "test@test.com"
124
+ from = "test@test.com"
125
+ reply_to = "testGuy"
126
+ subject = "test subject"
127
+ campaign = "test campaign"
128
+ stream = "test stream"
129
+ component = "test component"
130
+ schedule_at = DateTime.now
131
+
132
+ assert_raise RuntimeError do
133
+ MailSpy.add_instance(
134
+ :to => to,
135
+ :subject => subject,
136
+ :from => from,
137
+ :reply_to => reply_to,
138
+ :template_name => "NOT HERE",
139
+ :template_values => {},
140
+ :campaign => campaign,
141
+ :stream => stream,
142
+ :component => component,
143
+ :schedule_at => schedule_at
144
+ )
145
+ end
146
+ end
147
+ end
148
+
149
+ # ------------------------------------------- SEND_OUTSTANDING_EMAILS
150
+
151
+ #TODO need to document the testing methods for setting up the test_email
152
+ def test_send_outstanding_emails
153
+ initialize_mail_spy_test_esp
154
+
155
+ do_with_template do |template|
156
+ create_emails(template)
157
+ end
158
+
159
+ num_sent = MailSpy.send_outstanding_emails
160
+ assert(num_sent == 1, "We should have sent a email")
161
+ end
162
+
163
+ end
164
+ end
@@ -0,0 +1,9 @@
1
+ require 'test_helper'
2
+
3
+ module MailSpy
4
+ class StreamReportTest < ActiveSupport::TestCase
5
+ # test "the truth" do
6
+ # assert true
7
+ # end
8
+ end
9
+ end