postageapp 1.3.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (72) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +6 -0
  3. data/.travis.yml +9 -39
  4. data/{LICENSE → LICENSE.md} +1 -1
  5. data/README.md +117 -13
  6. data/Rakefile +15 -4
  7. data/VERSION +1 -0
  8. data/app/ingresses/action_mailbox/ingresses/postage_app/inbound_emails_controller.rb +52 -0
  9. data/app/ingresses/action_mailbox/ingresses/postage_app.rb +4 -0
  10. data/config/routes.rb +8 -0
  11. data/exe/postageapp +37 -0
  12. data/lib/generators/postageapp/postageapp_generator.rb +9 -6
  13. data/lib/postageapp/cli/command/config.rb +74 -0
  14. data/lib/postageapp/cli/command/create_mailbox.rb +21 -0
  15. data/lib/postageapp/cli/command/env.rb +58 -0
  16. data/lib/postageapp/cli/command/get_project_info.rb +3 -0
  17. data/lib/postageapp/cli/command.rb +110 -0
  18. data/lib/postageapp/cli.rb +14 -0
  19. data/lib/postageapp/configuration.rb +237 -74
  20. data/lib/postageapp/engine.rb +11 -0
  21. data/lib/postageapp/env.rb +9 -0
  22. data/lib/postageapp/mailer/mailer_4.rb +30 -14
  23. data/lib/postageapp/mailer.rb +1 -11
  24. data/lib/postageapp/rails/railtie.rb +1 -3
  25. data/lib/postageapp/request.rb +6 -1
  26. data/lib/postageapp.rb +53 -35
  27. data/log/.gitignore +1 -0
  28. data/postageapp.gemspec +7 -10
  29. data/script/with +2 -2
  30. data/test/gemfiles/Gemfile.rails-2.3.x +1 -1
  31. data/test/gemfiles/Gemfile.rails-3.0.x +1 -1
  32. data/test/gemfiles/Gemfile.rails-3.1.x +1 -1
  33. data/test/gemfiles/Gemfile.rails-3.2.x +1 -1
  34. data/test/gemfiles/Gemfile.rails-4.0.x +1 -1
  35. data/test/gemfiles/Gemfile.rails-4.1.x +1 -1
  36. data/test/gemfiles/Gemfile.rails-4.2.x +1 -2
  37. data/test/gemfiles/Gemfile.rails-5.0.x +2 -3
  38. data/test/gemfiles/Gemfile.rails-5.2.x +12 -0
  39. data/test/gemfiles/Gemfile.rails-6.0.x +12 -0
  40. data/test/gemfiles/Gemfile.rails-6.1.x +12 -0
  41. data/test/gemfiles/Gemfile.ruby +2 -3
  42. data/test/helper.rb +5 -3
  43. data/test/log/.gitignore +1 -0
  44. data/test/mailer/action_mailer_3/notifier.rb +1 -1
  45. data/test/tmp/.gitignore +1 -0
  46. data/test/travis_test.rb +58 -40
  47. data/test/{configuration_test.rb → unit/configuration_test.rb} +18 -12
  48. data/test/{failed_request_test.rb → unit/failed_request_test.rb} +6 -6
  49. data/test/{live_test.rb → unit/live_test.rb} +4 -39
  50. data/test/{mail_delivery_method_test.rb → unit/mail_delivery_method_test.rb} +1 -1
  51. data/test/{mailer_4_test.rb → unit/mailer_4_test.rb} +2 -2
  52. data/test/{mailer_helper_methods_test.rb → unit/mailer_helper_methods_test.rb} +4 -4
  53. data/test/{postageapp_test.rb → unit/postageapp_test.rb} +7 -1
  54. data/test/{rails_initialization_test.rb → unit/rails_initialization_test.rb} +2 -2
  55. data/test/{request_test.rb → unit/request_test.rb} +18 -17
  56. data/test/{response_test.rb → unit/response_test.rb} +4 -4
  57. data/test/unit/tmp/.gitignore +1 -0
  58. data/tmp/.gitignore +1 -0
  59. metadata +41 -48
  60. data/lib/postageapp/mailer/mailer_2.rb +0 -140
  61. data/lib/postageapp/mailer/mailer_3.rb +0 -190
  62. data/lib/postageapp/version.rb +0 -3
  63. data/test/mailer/action_mailer_2/notifier/with_body_and_attachment.erb +0 -1
  64. data/test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.html.erb +0 -1
  65. data/test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.plain.erb +0 -1
  66. data/test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.html.erb +0 -1
  67. data/test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.plain.erb +0 -1
  68. data/test/mailer/action_mailer_2/notifier/with_simple_view.erb +0 -1
  69. data/test/mailer/action_mailer_2/notifier/with_text_only_view.text.plain.erb +0 -1
  70. data/test/mailer/action_mailer_2/notifier.rb +0 -77
  71. data/test/mailer_2_test.rb +0 -95
  72. data/test/mailer_3_test.rb +0 -118
@@ -1,3 +0,0 @@
1
- module PostageApp
2
- VERSION = '1.3.0'.freeze
3
- end
@@ -1 +0,0 @@
1
- html and text: plain text
@@ -1 +0,0 @@
1
- simple view content
@@ -1 +0,0 @@
1
- text only: plain text
@@ -1,77 +0,0 @@
1
- # Test mailer for ActionMailer 2.x
2
-
3
- class Notifier < PostageApp::Mailer
4
- self.template_root = File.dirname(__FILE__)
5
-
6
- def blank
7
- # Empty method
8
- end
9
-
10
- def with_no_content
11
- setup_headers
12
- end
13
-
14
- def with_text_only_view
15
- setup_headers
16
- end
17
-
18
- def with_html_and_text_views
19
- setup_headers
20
- end
21
-
22
- def with_simple_view
23
- setup_headers
24
- end
25
-
26
- def with_manual_parts
27
- setup_headers
28
-
29
- part(
30
- :content_type => 'text/html',
31
- :body => 'html content'
32
- )
33
-
34
- part(
35
- content_type: 'text/plain',
36
- body: 'text content'
37
- )
38
-
39
- attachment(
40
- content_type: 'image/jpeg',
41
- filename: 'foo.jpg',
42
- body: '123456789'
43
- )
44
- end
45
-
46
- def with_body_and_attachment
47
- setup_headers
48
-
49
- attachment(
50
- content_type: 'image/jpeg',
51
- filename: 'foo.jpg',
52
- body: '123456789'
53
- )
54
- end
55
-
56
- def with_custom_postage_variables
57
- postageapp_template 'test-template'
58
- postageapp_variables 'variable' => 'value'
59
- postageapp_uid 'custom_uid'
60
- postageapp_api_key 'custom_api_key'
61
-
62
- from 'sender@example.com'
63
- subject 'Test Email'
64
-
65
- recipients(
66
- 'test1@example.net' => { 'name' => 'Test 1' },
67
- 'test2@example.net' => { 'name' => 'Test 2' }
68
- )
69
- end
70
-
71
- private
72
- def setup_headers
73
- recipients 'recipient@example.net'
74
- from 'sender@example.com'
75
- subject 'Test Email'
76
- end
77
- end
@@ -1,95 +0,0 @@
1
- require_relative './helper'
2
-
3
- class Mailer2Test < MiniTest::Test
4
- require_action_mailer(2) do
5
- require File.expand_path('mailer/action_mailer_2/notifier', File.dirname(__FILE__))
6
-
7
- puts "\e[0m\e[32mRunning #{File.basename(__FILE__)} for action_mailer #{ActionMailer::VERSION::STRING}\e[0m"
8
-
9
- def test_create_blank
10
- assert mail = Notifier.create_blank
11
-
12
- assert_equal 'send_message', mail.method
13
- assert_equal 'https://api.postageapp.com/v.1.0/send_message.json', mail.url.to_s
14
- assert mail.arguments.blank?
15
- end
16
-
17
- def test_create_with_no_content
18
- assert mail = Notifier.create_with_no_content
19
-
20
- assert_equal 'recipient@example.net', mail.arguments['recipients']
21
- assert_equal({ 'from' => 'sender@example.com', 'subject' => 'Test Email' }, mail.arguments['headers'])
22
- assert mail.arguments['content'].blank?
23
- end
24
-
25
- def test_create_with_text_only_view
26
- assert mail = Notifier.create_with_text_only_view
27
-
28
- assert_equal 'text only: plain text', mail.arguments['content']['text/plain']
29
- end
30
-
31
- def test_create_with_html_and_text_views
32
- assert mail = Notifier.create_with_html_and_text_views
33
-
34
- assert_equal 'html and text: plain text', mail.arguments['content']['text/plain']
35
- assert_equal 'html and text: html', mail.arguments['content']['text/html']
36
- end
37
-
38
- def test_deliver_with_html_and_text_views
39
- mock_successful_send
40
-
41
- assert response = Notifier.deliver_with_html_and_text_views
42
-
43
- assert response.is_a?(PostageApp::Response)
44
- assert response.ok?
45
- end
46
-
47
- def test_create_with_simple_view
48
- assert mail = Notifier.create_with_simple_view
49
- assert_equal 'simple view content', mail.arguments['content']['text/plain']
50
- end
51
-
52
- def test_create_with_manual_parts
53
- assert mail = Notifier.create_with_manual_parts
54
-
55
- assert_equal 'text content', mail.arguments['content']['text/plain']
56
- assert_equal 'html content', mail.arguments['content']['text/html']
57
- assert !mail.arguments['attachments'].blank?
58
- assert !mail.arguments['attachments']['foo.jpg']['content'].blank?
59
- assert_equal 'image/jpeg', mail.arguments['attachments']['foo.jpg']['content_type']
60
- end
61
-
62
- def test_create_with_body_and_attachment
63
- assert mail = Notifier.create_with_body_and_attachment
64
-
65
- assert !mail.arguments['content'].blank?
66
- assert !mail.arguments['content']['text/plain'].blank?
67
- assert_equal 'body text', mail.arguments['content']['text/plain']
68
- assert !mail.arguments['attachments'].blank?
69
- assert !mail.arguments['attachments']['foo.jpg']['content'].blank?
70
- assert_equal 'image/jpeg', mail.arguments['attachments']['foo.jpg']['content_type']
71
- end
72
-
73
- def test_create_with_custom_postage_variables
74
- assert mail = Notifier.create_with_custom_postage_variables
75
-
76
- assert_equal 'custom_uid', mail.uid
77
- assert_equal 'custom_api_key', mail.api_key
78
- assert_equal 'test-template', mail.arguments['template']
79
- assert_equal({ 'variable' => 'value' }, mail.arguments['variables'])
80
- assert_equal({ 'test2@example.net' => { 'name' => 'Test 2'},
81
- 'test1@example.net' => { 'name' => 'Test 1'}}, mail.arguments['recipients'])
82
- assert_equal 'text content', mail.arguments['content']['text/plain']
83
- assert_equal 'html content', mail.arguments['content']['text/html']
84
- end
85
-
86
- def test_create_with_recipient_override
87
- PostageApp.configuration.recipient_override = 'override@example.net'
88
-
89
- assert mail = Notifier.create_with_html_and_text_views
90
-
91
- assert_equal 'recipient@example.net', mail.arguments['recipients']
92
- assert_equal 'override@example.net', mail.arguments_to_send['arguments']['recipient_override']
93
- end
94
- end
95
- end
@@ -1,118 +0,0 @@
1
- require_relative './helper'
2
-
3
- class Mailer3Test < MiniTest::Test
4
- require_action_mailer(3) do
5
- require File.expand_path('mailer/action_mailer_3/notifier', File.dirname(__FILE__))
6
-
7
- puts "\e[0m\e[32mRunning #{File.basename(__FILE__)} for action_mailer #{ActionMailer::VERSION::STRING}\e[0m"
8
-
9
- def test_create_with_no_content
10
- mail = Notifier.with_no_content
11
-
12
- assert_equal({ }, mail.arguments['content'])
13
- end
14
-
15
- def test_create_with_no_subject
16
- mail = Notifier.with_no_subject
17
-
18
- assert mail.arguments['headers'][:subject].nil?
19
- end
20
-
21
- def test_create_with_simple_view
22
- mail = Notifier.with_simple_view
23
-
24
- assert_equal 'with layout simple view content', mail.arguments['content']['text/html']
25
- end
26
-
27
- def test_create_with_text_only_view
28
- mail = Notifier.with_text_only_view
29
-
30
- assert_equal 'text content', mail.arguments['content']['text/plain']
31
- end
32
-
33
- def test_create_with_html_and_text_views
34
- mail = Notifier.with_html_and_text_views
35
-
36
- assert_equal 'text content', mail.arguments['content']['text/plain']
37
- assert_equal 'with layout html content', mail.arguments['content']['text/html']
38
- end
39
-
40
- def test_deliver_with_html_and_text_views
41
- mock_successful_send
42
-
43
- assert response = Notifier.with_html_and_text_views.deliver
44
- assert response.is_a?(PostageApp::Response)
45
- assert response.ok?
46
- end
47
-
48
- def test_create_with_body_and_attachment_as_file
49
- mail = Notifier.with_body_and_attachment_as_file
50
-
51
- assert_equal 'manual body text', mail.arguments['content']['text/html']
52
- assert_equal 'text/plain', mail.arguments['attachments']['sample_file.txt']['content_type']
53
- assert_equal "RmlsZSBjb250ZW50\n", mail.arguments['attachments']['sample_file.txt']['content']
54
- end
55
-
56
- def test_create_with_body_and_attachment_as_hash
57
- mail = Notifier.with_body_and_attachment_as_hash
58
-
59
- assert_equal 'manual body text', mail.arguments['content']['text/html']
60
- assert_equal 'text/rich', mail.arguments['attachments']['sample_file.txt']['content_type']
61
- assert_equal "RmlsZSBjb250ZW50\n", mail.arguments['attachments']['sample_file.txt']['content']
62
- end
63
-
64
- def test_create_with_custom_postage_variables
65
- mail = Notifier.with_custom_postage_variables
66
-
67
- args = mail.arguments_to_send
68
-
69
- assert_equal 'custom_uid', args['uid']
70
- assert_equal 'custom_api_key', args['api_key']
71
-
72
- args = args['arguments']
73
-
74
- assert_equal(
75
- {
76
- 'test1@example.net' => { 'name' => 'Test 1' },
77
- 'test2@example.net' => { 'name' => 'Test 2' }
78
- },
79
- args['recipients']
80
- )
81
-
82
- assert_equal 'test-template', args['template']
83
- assert_equal({ 'variable' => 'value' }, args['variables'])
84
- assert_equal 'CustomValue1', args['headers']['CustomHeader1']
85
- assert_equal 'CustomValue2', args['headers']['CustomHeader2']
86
- assert_equal 'text content', args['content']['text/plain']
87
- assert_equal 'with layout html content', args['content']['text/html']
88
- end
89
-
90
- def test_create_with_recipient_override
91
- PostageApp.configuration.recipient_override = 'override@example.net'
92
-
93
- assert mail = Notifier.with_html_and_text_views
94
-
95
- assert_equal 'recipient@example.net', mail.arguments['recipients']
96
- assert_equal 'override@example.net', mail.arguments_to_send['arguments']['recipient_override']
97
- end
98
-
99
- def test_deliver_for_test_mailer
100
- mail = Notifier.with_simple_view
101
-
102
- mail.delivery_method(Mail::TestMailer)
103
- mail.deliver
104
-
105
- assert_equal [ mail ], ActionMailer::Base.deliveries
106
- end
107
-
108
- def test_deliver_for_not_performing_deliveries_with_test_mailer
109
- mail = Notifier.with_simple_view
110
-
111
- mail.perform_deliveries = false
112
- mail.delivery_method(Mail::TestMailer)
113
- mail.deliver
114
-
115
- assert_equal [ ], ActionMailer::Base.deliveries
116
- end
117
- end
118
- end