postageapp 1.0.9 → 1.0.10
Sign up to get free protection for your applications and to get access to all the features.
- data/VERSION +1 -1
- data/lib/postageapp.rb +1 -0
- data/lib/postageapp/failed_request.rb +6 -2
- data/lib/postageapp/request.rb +5 -1
- data/postageapp.gemspec +67 -69
- data/test/failed_request_test.rb +22 -1
- data/test/helper.rb +2 -2
- data/test/mailer_helper_methods_test.rb +2 -1
- metadata +5 -11
- data/.gitignore +0 -24
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
1.0.
|
1
|
+
1.0.10
|
data/lib/postageapp.rb
CHANGED
@@ -24,7 +24,9 @@ module PostageApp::FailedRequest
|
|
24
24
|
request = initialize_request(filename)
|
25
25
|
|
26
26
|
receipt_response = PostageApp::Request.new(:get_message_receipt, :uid => filename).send(true)
|
27
|
-
if receipt_response.
|
27
|
+
if receipt_response.fail?
|
28
|
+
return
|
29
|
+
elsif receipt_response.ok?
|
28
30
|
PostageApp.logger.info "NOT RESENDING FAILED REQUEST [#{filename}]"
|
29
31
|
File.delete(file_path(filename)) rescue nil
|
30
32
|
|
@@ -35,9 +37,11 @@ module PostageApp::FailedRequest
|
|
35
37
|
# Not a fail, so we can remove this file, if it was then
|
36
38
|
# there will be another attempt to resend
|
37
39
|
File.delete(file_path(filename)) rescue nil if !response.fail?
|
40
|
+
else
|
41
|
+
PostageApp.logger.info "NOT RESENDING FAILED REQUEST [#{filename}], RECEIPT CANNOT BE PROCESSED"
|
42
|
+
File.delete(file_path(filename)) rescue nil
|
38
43
|
end
|
39
44
|
end
|
40
|
-
|
41
45
|
return
|
42
46
|
end
|
43
47
|
|
data/lib/postageapp/request.rb
CHANGED
@@ -54,7 +54,11 @@ class PostageApp::Request
|
|
54
54
|
PostageApp.logger.info(response)
|
55
55
|
|
56
56
|
unless skip_failed_requests_processing
|
57
|
-
response.fail
|
57
|
+
if response.fail?
|
58
|
+
PostageApp::FailedRequest.store(self)
|
59
|
+
elsif response.ok?
|
60
|
+
PostageApp::FailedRequest.resend_all
|
61
|
+
end
|
58
62
|
end
|
59
63
|
|
60
64
|
response
|
data/postageapp.gemspec
CHANGED
@@ -1,95 +1,93 @@
|
|
1
1
|
# Generated by jeweler
|
2
2
|
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run
|
3
|
+
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
4
|
# -*- encoding: utf-8 -*-
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{postageapp}
|
8
|
-
s.version = "1.0.
|
8
|
+
s.version = "1.0.10"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["Oleg Khabarov, The Working Group Inc"]
|
12
|
-
s.date = %q{
|
12
|
+
s.date = %q{2011-01-06}
|
13
13
|
s.description = %q{Gem that interfaces with PostageApp.com service to send emails from web apps}
|
14
14
|
s.email = %q{oleg@twg.ca}
|
15
15
|
s.extra_rdoc_files = [
|
16
16
|
"LICENSE",
|
17
|
-
|
17
|
+
"README.md"
|
18
18
|
]
|
19
19
|
s.files = [
|
20
20
|
".document",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
"test/response_test.rb"
|
21
|
+
"LICENSE",
|
22
|
+
"README.md",
|
23
|
+
"Rakefile",
|
24
|
+
"VERSION",
|
25
|
+
"generators/postageapp/postageapp_generator.rb",
|
26
|
+
"generators/postageapp/templates/initializer.rb",
|
27
|
+
"generators/postageapp/templates/postageapp_tasks.rake",
|
28
|
+
"lib/generators/postageapp/postageapp_generator.rb",
|
29
|
+
"lib/postageapp.rb",
|
30
|
+
"lib/postageapp/configuration.rb",
|
31
|
+
"lib/postageapp/failed_request.rb",
|
32
|
+
"lib/postageapp/logger.rb",
|
33
|
+
"lib/postageapp/mailer.rb",
|
34
|
+
"lib/postageapp/mailer/mailer_2.rb",
|
35
|
+
"lib/postageapp/mailer/mailer_3.rb",
|
36
|
+
"lib/postageapp/rails/rails.rb",
|
37
|
+
"lib/postageapp/rails/railtie.rb",
|
38
|
+
"lib/postageapp/request.rb",
|
39
|
+
"lib/postageapp/response.rb",
|
40
|
+
"lib/postageapp/utils.rb",
|
41
|
+
"lib/postageapp/version.rb",
|
42
|
+
"postageapp.gemspec",
|
43
|
+
"rails/init.rb",
|
44
|
+
"test/configuration_test.rb",
|
45
|
+
"test/failed_request_test.rb",
|
46
|
+
"test/helper.rb",
|
47
|
+
"test/live_test.rb",
|
48
|
+
"test/mailer/action_mailer_2/notifier.rb",
|
49
|
+
"test/mailer/action_mailer_2/notifier/with_body_and_attachment.erb",
|
50
|
+
"test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.html.erb",
|
51
|
+
"test/mailer/action_mailer_2/notifier/with_custom_postage_variables.text.plain.erb",
|
52
|
+
"test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.html.erb",
|
53
|
+
"test/mailer/action_mailer_2/notifier/with_html_and_text_views.text.plain.erb",
|
54
|
+
"test/mailer/action_mailer_2/notifier/with_simple_view.erb",
|
55
|
+
"test/mailer/action_mailer_2/notifier/with_text_only_view.text.plain.erb",
|
56
|
+
"test/mailer/action_mailer_3/notifier.rb",
|
57
|
+
"test/mailer/action_mailer_3/notifier/with_custom_postage_variables.html.erb",
|
58
|
+
"test/mailer/action_mailer_3/notifier/with_custom_postage_variables.text.erb",
|
59
|
+
"test/mailer/action_mailer_3/notifier/with_html_and_text_views.html.erb",
|
60
|
+
"test/mailer/action_mailer_3/notifier/with_html_and_text_views.text.erb",
|
61
|
+
"test/mailer/action_mailer_3/notifier/with_old_api.html.erb",
|
62
|
+
"test/mailer/action_mailer_3/notifier/with_old_api.text.erb",
|
63
|
+
"test/mailer/action_mailer_3/notifier/with_simple_view.erb",
|
64
|
+
"test/mailer/action_mailer_3/notifier/with_text_only_view.text.erb",
|
65
|
+
"test/mailer_2_test.rb",
|
66
|
+
"test/mailer_3_test.rb",
|
67
|
+
"test/mailer_helper_methods_test.rb",
|
68
|
+
"test/postageapp_test.rb",
|
69
|
+
"test/rails_initialization_test.rb",
|
70
|
+
"test/request_test.rb",
|
71
|
+
"test/response_test.rb"
|
73
72
|
]
|
74
73
|
s.homepage = %q{http://github.com/postageapp/postageapp-ruby}
|
75
|
-
s.rdoc_options = ["--charset=UTF-8"]
|
76
74
|
s.require_paths = ["lib"]
|
77
75
|
s.rubygems_version = %q{1.3.7}
|
78
76
|
s.summary = %q{Easier way to send email from web apps}
|
79
77
|
s.test_files = [
|
80
78
|
"test/configuration_test.rb",
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
79
|
+
"test/failed_request_test.rb",
|
80
|
+
"test/helper.rb",
|
81
|
+
"test/live_test.rb",
|
82
|
+
"test/mailer/action_mailer_2/notifier.rb",
|
83
|
+
"test/mailer/action_mailer_3/notifier.rb",
|
84
|
+
"test/mailer_2_test.rb",
|
85
|
+
"test/mailer_3_test.rb",
|
86
|
+
"test/mailer_helper_methods_test.rb",
|
87
|
+
"test/postageapp_test.rb",
|
88
|
+
"test/rails_initialization_test.rb",
|
89
|
+
"test/request_test.rb",
|
90
|
+
"test/response_test.rb"
|
93
91
|
]
|
94
92
|
|
95
93
|
if s.respond_to? :specification_version then
|
data/test/failed_request_test.rb
CHANGED
@@ -66,7 +66,7 @@ class FailedRequestTest < Test::Unit::TestCase
|
|
66
66
|
|
67
67
|
request = PostageApp::Request.new(:get_project_info)
|
68
68
|
|
69
|
-
message_receipt_response = stub(:ok? => false, :not_found? => true)
|
69
|
+
message_receipt_response = stub(:fail? => false, :ok? => false, :not_found? => true)
|
70
70
|
message_receipt_request = stub(:send => message_receipt_response)
|
71
71
|
PostageApp::Request.stubs(:new).with{|a,b| a == :get_message_receipt}.returns(message_receipt_request)
|
72
72
|
|
@@ -76,4 +76,25 @@ class FailedRequestTest < Test::Unit::TestCase
|
|
76
76
|
assert !File.exists?(file_path)
|
77
77
|
end
|
78
78
|
|
79
|
+
def test_resend_all_failure
|
80
|
+
mock_failed_send
|
81
|
+
request = PostageApp::Request.new(:send_message, {
|
82
|
+
:headers => { 'from' => 'sender@test.test',
|
83
|
+
'subject' => 'Test Message'},
|
84
|
+
:recipients => 'test@test.test',
|
85
|
+
:content => {
|
86
|
+
'text/plain' => 'text content',
|
87
|
+
'text/html' => 'html content'
|
88
|
+
}
|
89
|
+
})
|
90
|
+
response = request.send
|
91
|
+
assert response.fail?
|
92
|
+
file_path = File.join(PostageApp::FailedRequest.store_path, request.uid)
|
93
|
+
assert File.exists?(file_path)
|
94
|
+
|
95
|
+
# Forcing to resend. Should quit right away as we can't connect
|
96
|
+
PostageApp::FailedRequest.resend_all
|
97
|
+
|
98
|
+
assert File.exists?(file_path)
|
99
|
+
end
|
79
100
|
end
|
data/test/helper.rb
CHANGED
@@ -35,12 +35,12 @@ class Test::Unit::TestCase
|
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
def mock_successful_send
|
38
|
+
def mock_successful_send(status = 'ok')
|
39
39
|
Net::HTTP.any_instance.stubs(:post).returns(Net::HTTPResponse.new(nil, nil, nil))
|
40
40
|
Net::HTTPResponse.any_instance.stubs(:body).returns({
|
41
41
|
:response => {
|
42
42
|
:uid => 'sha1hashuid23456789012345678901234567890',
|
43
|
-
:status =>
|
43
|
+
:status => status
|
44
44
|
},
|
45
45
|
:data => {
|
46
46
|
:message => { :id => 999 }
|
@@ -15,7 +15,8 @@ class MailerHelperMethodsTest < Test::Unit::TestCase
|
|
15
15
|
assert_equal ['test@test.test'], request.to
|
16
16
|
assert_equal ['sender@test.test'], request.from
|
17
17
|
assert_equal 'Test Message', request.subject
|
18
|
-
|
18
|
+
assert_match 'html content', request.body
|
19
|
+
assert_match 'text content', request.body
|
19
20
|
end
|
20
21
|
|
21
22
|
end
|
metadata
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: postageapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash: 5
|
5
4
|
prerelease: false
|
6
5
|
segments:
|
7
6
|
- 1
|
8
7
|
- 0
|
9
|
-
-
|
10
|
-
version: 1.0.
|
8
|
+
- 10
|
9
|
+
version: 1.0.10
|
11
10
|
platform: ruby
|
12
11
|
authors:
|
13
12
|
- Oleg Khabarov, The Working Group Inc
|
@@ -15,7 +14,7 @@ autorequire:
|
|
15
14
|
bindir: bin
|
16
15
|
cert_chain: []
|
17
16
|
|
18
|
-
date:
|
17
|
+
date: 2011-01-06 00:00:00 -05:00
|
19
18
|
default_executable:
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
@@ -26,7 +25,6 @@ dependencies:
|
|
26
25
|
requirements:
|
27
26
|
- - ">="
|
28
27
|
- !ruby/object:Gem::Version
|
29
|
-
hash: 11
|
30
28
|
segments:
|
31
29
|
- 1
|
32
30
|
- 4
|
@@ -42,7 +40,6 @@ dependencies:
|
|
42
40
|
requirements:
|
43
41
|
- - ">="
|
44
42
|
- !ruby/object:Gem::Version
|
45
|
-
hash: 43
|
46
43
|
segments:
|
47
44
|
- 0
|
48
45
|
- 9
|
@@ -61,7 +58,6 @@ extra_rdoc_files:
|
|
61
58
|
- README.md
|
62
59
|
files:
|
63
60
|
- .document
|
64
|
-
- .gitignore
|
65
61
|
- LICENSE
|
66
62
|
- README.md
|
67
63
|
- Rakefile
|
@@ -118,8 +114,8 @@ homepage: http://github.com/postageapp/postageapp-ruby
|
|
118
114
|
licenses: []
|
119
115
|
|
120
116
|
post_install_message:
|
121
|
-
rdoc_options:
|
122
|
-
|
117
|
+
rdoc_options: []
|
118
|
+
|
123
119
|
require_paths:
|
124
120
|
- lib
|
125
121
|
required_ruby_version: !ruby/object:Gem::Requirement
|
@@ -127,7 +123,6 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
123
|
requirements:
|
128
124
|
- - ">="
|
129
125
|
- !ruby/object:Gem::Version
|
130
|
-
hash: 3
|
131
126
|
segments:
|
132
127
|
- 0
|
133
128
|
version: "0"
|
@@ -136,7 +131,6 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
136
131
|
requirements:
|
137
132
|
- - ">="
|
138
133
|
- !ruby/object:Gem::Version
|
139
|
-
hash: 3
|
140
134
|
segments:
|
141
135
|
- 0
|
142
136
|
version: "0"
|
data/.gitignore
DELETED