action_smser 1.2.0 → 1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +10 -0
- data/app/models/action_smser/delivery_report.rb +1 -1
- data/app/views/action_smser/delivery_reports/index.html.erb +4 -4
- data/lib/action_smser.rb +1 -0
- data/lib/action_smser/base.rb +6 -8
- data/lib/action_smser/delivery_methods/delayed_job.rb +46 -0
- data/lib/action_smser/delivery_methods/nexmo.rb +2 -10
- data/lib/action_smser/delivery_methods/simple_http.rb +2 -5
- data/lib/action_smser/version.rb +1 -1
- data/test/dummy/log/test.log +10538 -0
- data/test/unit/action_smser/delivery_methods/delayed_job_test.rb +53 -0
- data/test/unit/action_smser/delivery_report_test.rb +3 -1
- metadata +21 -4
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require 'test_helper'
|
3
|
+
|
4
|
+
# We mock delayed_job
|
5
|
+
module Delayed
|
6
|
+
class Job
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
class ActionSmser::DelayedJobTest < ActiveSupport::TestCase
|
11
|
+
class MockSms<ActionSmser::Base
|
12
|
+
def basic_sms(to, from, body)
|
13
|
+
sms(:to => to, :from => from, :body => body)
|
14
|
+
end
|
15
|
+
end
|
16
|
+
|
17
|
+
setup do
|
18
|
+
@receivers = ["555123555", "123555123"]
|
19
|
+
@sender = "555666"
|
20
|
+
@body = "Body with ääkköset end"
|
21
|
+
@sms = MockSms.basic_sms(@receivers, @sender, @body)
|
22
|
+
|
23
|
+
@sms.delivery_options[:delivery_method] = :delayed_job
|
24
|
+
@sms.delivery_options[:delayed_job] = {:delivery_method => :nexmo, :priority => 5}
|
25
|
+
assert_equal ActionSmser::DeliveryMethods::DelayedJob, @sms.delivery_method, "cant run tests, wrong delivery method"
|
26
|
+
end
|
27
|
+
|
28
|
+
test "should be able to deliver and call enqueue for all receivers" do
|
29
|
+
|
30
|
+
::Delayed::Job.expects(:enqueue).twice().returns(1)
|
31
|
+
@sms_delivery = @sms.deliver
|
32
|
+
assert @sms_delivery
|
33
|
+
assert_equal 2, @sms_delivery.count
|
34
|
+
end
|
35
|
+
|
36
|
+
test "test that serializing is ok" do
|
37
|
+
smsdj = ActionSmser::DeliveryMethods::DelayedJob::SmsDeliverJob.new(@sms, @sms.to_numbers_array.first)
|
38
|
+
|
39
|
+
[:body, :from, :sms_type, :re_delivery_of_delivery_report_id, :ttl, :delivery_info].each do |var|
|
40
|
+
assert_equal smsdj.send(var), @sms.send(var)
|
41
|
+
end
|
42
|
+
|
43
|
+
assert smsdj.body.object_id != @sms.body.object_id, "It should make copy of all values, not use the same objects."
|
44
|
+
|
45
|
+
assert_equal smsdj.delivery_options, @sms.delivery_options.merge(:delivery_method => @sms.delivery_options[:delayed_job][:delivery_method])
|
46
|
+
|
47
|
+
assert_equal smsdj.to, @sms.to_numbers_array.first
|
48
|
+
|
49
|
+
assert_equal :nexmo, smsdj.delivery_options[:delivery_method], "Should set the deliverymethod to nexmo"
|
50
|
+
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
@@ -76,7 +76,9 @@ class ActionSmser::DeliveryReportTest < ActiveSupport::TestCase
|
|
76
76
|
re_delivarable_sms = @dr.re_delivarable_sms()
|
77
77
|
|
78
78
|
assert re_delivarable_sms
|
79
|
-
#
|
79
|
+
assert_equal "#{@dr.sms_type}.re_delivery", re_delivarable_sms.sms_type
|
80
|
+
assert_equal @dr.id, re_delivarable_sms.re_delivery_of_delivery_report_id
|
81
|
+
|
80
82
|
assert ActionSmser::DeliveryReport.find(@dr.id).re_delivered?
|
81
83
|
|
82
84
|
dr_result = re_delivarable_sms.deliver
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: action_smser
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 29
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 1.2.
|
9
|
+
- 1
|
10
|
+
version: 1.2.1
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Olli Huotari
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2012-
|
18
|
+
date: 2012-02-23 00:00:00 Z
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: rails
|
@@ -60,6 +60,20 @@ dependencies:
|
|
60
60
|
version: "0"
|
61
61
|
type: :development
|
62
62
|
version_requirements: *id003
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: delayed_job
|
65
|
+
prerelease: false
|
66
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
67
|
+
none: false
|
68
|
+
requirements:
|
69
|
+
- - ">="
|
70
|
+
- !ruby/object:Gem::Version
|
71
|
+
hash: 3
|
72
|
+
segments:
|
73
|
+
- 0
|
74
|
+
version: "0"
|
75
|
+
type: :development
|
76
|
+
version_requirements: *id004
|
63
77
|
description: ActionSmser == SMS && ActionMailer. Simple way to use SMS (Short Message Service) in the same way as ActionMailer. Includes also delivery reports and easy way to add custom gateways (simple http and nexmo by default).
|
64
78
|
email:
|
65
79
|
- olli.huotari@iki.fi
|
@@ -87,6 +101,7 @@ files:
|
|
87
101
|
- lib/action_smser/engine.rb
|
88
102
|
- lib/action_smser/delivery_methods/simple_http.rb
|
89
103
|
- lib/action_smser/delivery_methods/test_array.rb
|
104
|
+
- lib/action_smser/delivery_methods/delayed_job.rb
|
90
105
|
- lib/action_smser/delivery_methods/nexmo.rb
|
91
106
|
- lib/action_smser/version.rb
|
92
107
|
- lib/action_smser/base.rb
|
@@ -136,6 +151,7 @@ files:
|
|
136
151
|
- test/test_helper.rb
|
137
152
|
- test/unit/action_smser/delivery_methods/simple_http_test.rb
|
138
153
|
- test/unit/action_smser/delivery_methods/test_array_test.rb
|
154
|
+
- test/unit/action_smser/delivery_methods/delayed_job_test.rb
|
139
155
|
- test/unit/action_smser/delivery_methods/nexmo_test.rb
|
140
156
|
- test/unit/action_smser/base_test.rb
|
141
157
|
- test/unit/action_smser/delivery_report_test.rb
|
@@ -216,6 +232,7 @@ test_files:
|
|
216
232
|
- test/test_helper.rb
|
217
233
|
- test/unit/action_smser/delivery_methods/simple_http_test.rb
|
218
234
|
- test/unit/action_smser/delivery_methods/test_array_test.rb
|
235
|
+
- test/unit/action_smser/delivery_methods/delayed_job_test.rb
|
219
236
|
- test/unit/action_smser/delivery_methods/nexmo_test.rb
|
220
237
|
- test/unit/action_smser/base_test.rb
|
221
238
|
- test/unit/action_smser/delivery_report_test.rb
|