govdelivery-tms 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +1 -1
- data/README.md +8 -8
- data/govdelivery-tms.gemspec +2 -2
- data/lib/{govdelivery-tms → govdelivery/tms}/base.rb +4 -4
- data/lib/{govdelivery-tms → govdelivery/tms}/client.rb +9 -9
- data/lib/{govdelivery-tms → govdelivery/tms}/collection_resource.rb +2 -2
- data/lib/{govdelivery-tms → govdelivery/tms}/connection.rb +4 -4
- data/lib/{govdelivery-tms → govdelivery/tms}/errors.rb +1 -1
- data/lib/govdelivery/tms/instance_resource.rb +219 -0
- data/lib/{govdelivery-tms → govdelivery/tms}/link_header.rb +0 -0
- data/lib/{govdelivery-tms → govdelivery/tms}/logger.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/mail/delivery_method.rb +11 -11
- data/lib/govdelivery/tms/resource/collections.rb +98 -0
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/command.rb +7 -7
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/command_action.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/command_type.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_message.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_recipient.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_recipient_click.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_recipient_open.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/email_template.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/from_address.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/inbound_sms_message.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_acknowledgement.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_alert.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_category.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_cog_profile.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_event_code.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_nwem_area.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_nwem_authorization.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_nwem_auxilary_data.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_response_type.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/ipaws_static_resource.rb +2 -2
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/keyword.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/recipient.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/sms_message.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/resource/webhook.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/util/core_ext.rb +1 -1
- data/lib/{govdelivery-tms → govdelivery/tms}/util/hal_link_parser.rb +2 -2
- data/lib/govdelivery/tms/version.rb +5 -0
- data/lib/govdelivery-tms/instance_resource.rb +7 -7
- data/lib/govdelivery-tms.rb +38 -36
- data/spec/client_spec.rb +18 -18
- data/spec/command_types_spec.rb +6 -6
- data/spec/email_message_spec.rb +58 -58
- data/spec/email_template_spec.rb +39 -39
- data/spec/errors_spec.rb +3 -3
- data/spec/from_address_spec.rb +22 -22
- data/spec/inbound_sms_messages_spec.rb +5 -5
- data/spec/instance_resource_spec.rb +14 -14
- data/spec/ipaws_acknowledgement_spec.rb +6 -6
- data/spec/ipaws_alerts_spec.rb +31 -31
- data/spec/ipaws_cog_profile_spec.rb +26 -26
- data/spec/ipaws_event_codes_spec.rb +5 -5
- data/spec/ipaws_nwem_areas_spec.rb +22 -22
- data/spec/ipaws_nwem_authorization_spec.rb +6 -6
- data/spec/keyword_spec.rb +23 -23
- data/spec/keywords_spec.rb +5 -5
- data/spec/mail/delivery_method_spec.rb +19 -19
- data/spec/sms_message_spec.rb +29 -29
- data/spec/sms_messages_spec.rb +7 -7
- data/spec/spec_helper.rb +2 -3
- data/spec/tms_spec.rb +2 -2
- metadata +50 -41
- checksums.yaml +0 -15
- data/lib/govdelivery-tms/resource/collections.rb +0 -98
- data/lib/govdelivery-tms/version.rb +0 -3
data/spec/email_template_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TMS::EmailTemplate do
|
3
|
+
describe GovDelivery::TMS::EmailTemplate do
|
4
4
|
context "creating a list of email templates" do
|
5
5
|
let(:client) do
|
6
6
|
double('client')
|
7
7
|
end
|
8
8
|
before do
|
9
|
-
@templates = TMS::EmailTemplates.new(client, '/templates/email')
|
9
|
+
@templates = GovDelivery::TMS::EmailTemplates.new(client, '/templates/email')
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should be able to get a list of email templates' do
|
@@ -24,9 +24,9 @@ describe TMS::EmailTemplate do
|
|
24
24
|
}
|
25
25
|
]
|
26
26
|
|
27
|
-
@templates.client.
|
27
|
+
expect(@templates.client).to receive('get').with('/templates/email').and_return(double('response', status: 200, body: response, headers: {}))
|
28
28
|
@templates.get
|
29
|
-
@templates.collection.length.
|
29
|
+
expect(@templates.collection.length).to eq(1)
|
30
30
|
end
|
31
31
|
end
|
32
32
|
|
@@ -35,13 +35,13 @@ describe TMS::EmailTemplate do
|
|
35
35
|
double('client')
|
36
36
|
end
|
37
37
|
before do
|
38
|
-
@template = TMS::EmailTemplate.new(client, '/templates/email', {
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
42
|
-
:
|
43
|
-
:
|
44
|
-
:
|
38
|
+
@template = GovDelivery::TMS::EmailTemplate.new(client, '/templates/email', {
|
39
|
+
body: "Template 1",
|
40
|
+
subject: "This is the template 1 subject",
|
41
|
+
link_tracking_parameters: "test=ok&hello=world",
|
42
|
+
macros: {"MACRO1" => "1"},
|
43
|
+
open_tracking_enabled: true,
|
44
|
+
click_tracking_enabled: true,
|
45
45
|
})
|
46
46
|
end
|
47
47
|
|
@@ -49,24 +49,24 @@ describe TMS::EmailTemplate do
|
|
49
49
|
@template.links[:from_address] = "1"
|
50
50
|
@template.links[:invalid] = "2"
|
51
51
|
links = @template.to_json[:_links]
|
52
|
-
links[:from_address].
|
53
|
-
links[:invalid].
|
52
|
+
expect(links[:from_address]).to eq('1')
|
53
|
+
expect(links[:invalid]).to be_nil
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'should clear the links property after a successful post' do
|
57
57
|
@template.links[:from_address] = "1"
|
58
|
-
@template.client.
|
58
|
+
expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 201, body: {}))
|
59
59
|
@template.post
|
60
60
|
links = @template.to_json[:_links]
|
61
|
-
links[:from_address].
|
61
|
+
expect(links[:from_address]).to be_nil
|
62
62
|
end
|
63
63
|
|
64
64
|
it 'should not clear the links property after an invalid post' do
|
65
65
|
@template.links[:from_address] = "1"
|
66
|
-
@template.client.
|
66
|
+
expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 400, body: {}))
|
67
67
|
@template.post
|
68
68
|
links = @template.to_json[:_links]
|
69
|
-
links[:from_address].
|
69
|
+
expect(links[:from_address]).to eq("1")
|
70
70
|
end
|
71
71
|
|
72
72
|
it 'should post successfully' do
|
@@ -81,17 +81,17 @@ describe TMS::EmailTemplate do
|
|
81
81
|
'created_at' => "sometime",
|
82
82
|
'_links' => {"self" => "/templates/email/1","account" => "/accounts/1","from_address" => "/from_addresses/1"}
|
83
83
|
}
|
84
|
-
@template.client.
|
84
|
+
expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 201, body: response))
|
85
85
|
@template.post
|
86
|
-
@template.id.
|
87
|
-
@template.body.
|
88
|
-
@template.subject.
|
89
|
-
@template.link_tracking_parameters.
|
90
|
-
@template.macros.
|
91
|
-
@template.open_tracking_enabled.
|
92
|
-
@template.click_tracking_enabled.
|
93
|
-
@template.created_at.
|
94
|
-
@template.from_address.
|
86
|
+
expect(@template.id).to eq('1')
|
87
|
+
expect(@template.body).to eq('Template 1')
|
88
|
+
expect(@template.subject).to eq('This is the template 1 subject')
|
89
|
+
expect(@template.link_tracking_parameters).to eq('test=ok&hello=world')
|
90
|
+
expect(@template.macros).to eq({"MACRO1"=>"1"})
|
91
|
+
expect(@template.open_tracking_enabled).to eq(true)
|
92
|
+
expect(@template.click_tracking_enabled).to eq(true)
|
93
|
+
expect(@template.created_at).to eq('sometime')
|
94
|
+
expect(@template.from_address).to be_a(GovDelivery::TMS::FromAddress)
|
95
95
|
end
|
96
96
|
end
|
97
97
|
|
@@ -100,23 +100,23 @@ describe TMS::EmailTemplate do
|
|
100
100
|
double('client')
|
101
101
|
end
|
102
102
|
before do
|
103
|
-
@template = TMS::EmailTemplate.new(client, '/templates/email/1')
|
103
|
+
@template = GovDelivery::TMS::EmailTemplate.new(client, '/templates/email/1')
|
104
104
|
end
|
105
105
|
|
106
106
|
it 'should handle errors' do
|
107
|
-
response = {'errors' => {:
|
108
|
-
@template.client.
|
107
|
+
response = {'errors' => {body: "can't be nil"}}
|
108
|
+
expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 422, body: response))
|
109
109
|
@template.post
|
110
|
-
@template.errors.
|
110
|
+
expect(@template.errors).to eq({body: "can't be nil"})
|
111
111
|
end
|
112
112
|
|
113
113
|
it 'should handle 401 errors' do
|
114
|
-
@template.client.
|
114
|
+
expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 401))
|
115
115
|
expect {@template.post}.to raise_error("401 Not Authorized")
|
116
116
|
end
|
117
117
|
|
118
118
|
it 'should handle 404 errors' do
|
119
|
-
@template.client.
|
119
|
+
expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 404))
|
120
120
|
expect {@template.post}.to raise_error("Can't POST to /templates/email/1")
|
121
121
|
end
|
122
122
|
end
|
@@ -126,23 +126,23 @@ describe TMS::EmailTemplate do
|
|
126
126
|
double('client')
|
127
127
|
end
|
128
128
|
before do
|
129
|
-
@template = TMS::EmailTemplate.new(client, '/templates/email')
|
129
|
+
@template = GovDelivery::TMS::EmailTemplate.new(client, '/templates/email')
|
130
130
|
end
|
131
131
|
|
132
132
|
it 'should handle errors' do
|
133
|
-
response = {'errors' => {:
|
134
|
-
@template.client.
|
133
|
+
response = {'errors' => {body: "can't be nil"}}
|
134
|
+
expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 422, body: response))
|
135
135
|
@template.post
|
136
|
-
@template.errors.
|
136
|
+
expect(@template.errors).to eq({body: "can't be nil"})
|
137
137
|
end
|
138
138
|
|
139
139
|
it 'should handle 401 errors' do
|
140
|
-
@template.client.
|
140
|
+
expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 401))
|
141
141
|
expect {@template.post}.to raise_error("401 Not Authorized")
|
142
142
|
end
|
143
143
|
|
144
144
|
it 'should handle 404 errors' do
|
145
|
-
@template.client.
|
145
|
+
expect(@template.client).to receive('post').with(@template).and_return(double('response', status: 404))
|
146
146
|
expect {@template.post}.to raise_error("Can't POST to /templates/email")
|
147
147
|
end
|
148
148
|
end
|
data/spec/errors_spec.rb
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TMS::Errors do
|
3
|
+
describe GovDelivery::TMS::Errors do
|
4
4
|
context "an errors hash" do
|
5
5
|
let(:object_with_errors) do
|
6
6
|
double('instance', href: 'href', errors: {"body" => ["can't be blank"], "subject" => ["can't be blank"]})
|
7
7
|
end
|
8
|
-
subject { TMS::Errors::InvalidVerb.new(object_with_errors) }
|
8
|
+
subject { GovDelivery::TMS::Errors::InvalidVerb.new(object_with_errors) }
|
9
9
|
it 'should work' do
|
10
|
-
subject.message.
|
10
|
+
expect(subject.message).to match(/body can't be blank, subject can't be blank/)
|
11
11
|
end
|
12
12
|
end
|
13
13
|
end
|
data/spec/from_address_spec.rb
CHANGED
@@ -1,12 +1,12 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TMS::FromAddress do
|
3
|
+
describe GovDelivery::TMS::FromAddress do
|
4
4
|
context "creating a list of from addresses" do
|
5
5
|
let(:client) do
|
6
6
|
double('client')
|
7
7
|
end
|
8
8
|
before do
|
9
|
-
@fromaddresses = TMS::FromAddress.new(client, '/from_addresses')
|
9
|
+
@fromaddresses = GovDelivery::TMS::FromAddress.new(client, '/from_addresses')
|
10
10
|
end
|
11
11
|
|
12
12
|
it 'should be able to get a list of email templates' do
|
@@ -19,9 +19,9 @@ describe TMS::FromAddress do
|
|
19
19
|
'_links' => {"self" => "/from_addresses/1"}
|
20
20
|
}]
|
21
21
|
|
22
|
-
@fromaddresses.client.
|
22
|
+
expect(@fromaddresses.client).to receive('get').with('/from_addresses').and_return(double('/from_addresses', status: 200, body: @from_addresses))
|
23
23
|
@fromaddresses.get
|
24
|
-
@fromaddresses.
|
24
|
+
expect(@fromaddresses).to eq(@fromaddresses)
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
@@ -31,11 +31,11 @@ describe TMS::FromAddress do
|
|
31
31
|
end
|
32
32
|
|
33
33
|
before do
|
34
|
-
@fromaddress = TMS::FromAddress.new(client, '/from_addresses', {
|
35
|
-
:
|
36
|
-
:
|
37
|
-
:
|
38
|
-
:
|
34
|
+
@fromaddress = GovDelivery::TMS::FromAddress.new(client, '/from_addresses', {
|
35
|
+
from_email: "something@evotest.govdelivery.com",
|
36
|
+
reply_to_email: "something@evotest.govdelivery.com",
|
37
|
+
bounce_email: "something@evotest.govdelivery.com",
|
38
|
+
is_default: true})
|
39
39
|
end
|
40
40
|
|
41
41
|
it 'should post successfully' do
|
@@ -47,14 +47,14 @@ describe TMS::FromAddress do
|
|
47
47
|
'created_at' => "sometime",
|
48
48
|
'_links' => {"self" => "/from_addresses/1"}
|
49
49
|
}
|
50
|
-
@fromaddress.client.
|
50
|
+
expect(@fromaddress.client).to receive('post').with(@fromaddress).and_return(double('response', status: 201, body: response ))
|
51
51
|
@fromaddress.post
|
52
|
-
@fromaddress.from_email.
|
53
|
-
@fromaddress.reply_to_email.
|
54
|
-
@fromaddress.bounce_email.
|
55
|
-
@fromaddress.is_default.
|
56
|
-
@fromaddress.created_at.
|
57
|
-
@fromaddress.href.
|
52
|
+
expect(@fromaddress.from_email).to eq("something@evotest.govdelivery.com")
|
53
|
+
expect(@fromaddress.reply_to_email).to eq("something@evotest.govdelivery.com")
|
54
|
+
expect(@fromaddress.bounce_email).to eq("something@evotest.govdelivery.com")
|
55
|
+
expect(@fromaddress.is_default).to eq(true)
|
56
|
+
expect(@fromaddress.created_at).to eq("sometime")
|
57
|
+
expect(@fromaddress.href).to eq("/from_addresses/1")
|
58
58
|
end
|
59
59
|
end
|
60
60
|
|
@@ -63,23 +63,23 @@ describe TMS::FromAddress do
|
|
63
63
|
double('client')
|
64
64
|
end
|
65
65
|
before do
|
66
|
-
@fromaddress = TMS::FromAddress.new(client, '/from_addresses/1')
|
66
|
+
@fromaddress = GovDelivery::TMS::FromAddress.new(client, '/from_addresses/1')
|
67
67
|
end
|
68
68
|
|
69
69
|
it 'should handle errors' do
|
70
|
-
response = {'errors' => {:
|
71
|
-
@fromaddress.client.
|
70
|
+
response = {'errors' => {from_email: "can't be nil"}}
|
71
|
+
expect(@fromaddress.client).to receive('post').with(@fromaddress).and_return(double('response', status: 422, body: response))
|
72
72
|
@fromaddress.post
|
73
|
-
@fromaddress.errors.
|
73
|
+
expect(@fromaddress.errors).to eq({from_email: "can't be nil"})
|
74
74
|
end
|
75
75
|
|
76
76
|
it 'should handle 401 errors' do
|
77
|
-
@fromaddress.client.
|
77
|
+
expect(@fromaddress.client).to receive('post').with(@fromaddress).and_return(double('response', status: 401))
|
78
78
|
expect {@fromaddress.post}.to raise_error("401 Not Authorized")
|
79
79
|
end
|
80
80
|
|
81
81
|
it 'should handle 404 errors' do
|
82
|
-
@fromaddress.client.
|
82
|
+
expect(@fromaddress.client).to receive('post').with(@fromaddress).and_return(double('response', status: 404))
|
83
83
|
expect {@fromaddress.post}.to raise_error("Can't POST to /from_addresses/1")
|
84
84
|
end
|
85
85
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TMS::InboundSmsMessages do
|
3
|
+
describe GovDelivery::TMS::InboundSmsMessages do
|
4
4
|
context "creating a new inbound messages list" do
|
5
5
|
let(:client) do
|
6
6
|
double('client')
|
7
7
|
end
|
8
8
|
before do
|
9
|
-
@messages = TMS::InboundSmsMessages.new(client, '/inbound_messages')
|
9
|
+
@messages = GovDelivery::TMS::InboundSmsMessages.new(client, '/inbound_messages')
|
10
10
|
end
|
11
11
|
it 'should GET itself' do
|
12
|
-
body = [{:
|
13
|
-
@messages.client.
|
12
|
+
body = [{body:"HELP", from:"+16125551212", created_at:"a while ago", to:"(651) 433-6258"}, {body:"STOP", from:"+16125551212", created_at:"a while ago", to:"(651) 433-6258"}]
|
13
|
+
expect(@messages.client).to receive(:get).and_return(double('response', body: body, status: 200, headers: {}))
|
14
14
|
|
15
15
|
@messages.get
|
16
|
-
@messages.collection.length.
|
16
|
+
expect(@messages.collection.length).to eq(2)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -1,19 +1,19 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
class Foo
|
3
|
-
include TMS::InstanceResource
|
3
|
+
include GovDelivery::TMS::InstanceResource
|
4
4
|
writeable_attributes :bar
|
5
5
|
collection_attribute :blah, 'EmailMessage'
|
6
6
|
readonly_collection_attribute :shah, 'EmailMessage'
|
7
7
|
end
|
8
8
|
|
9
|
-
describe TMS::InstanceResource do
|
9
|
+
describe GovDelivery::TMS::InstanceResource do
|
10
10
|
context "creating a new inbound messages list" do
|
11
11
|
let(:happy_response) do
|
12
|
-
double(:
|
12
|
+
double(status: 201, body: {})
|
13
13
|
end
|
14
14
|
|
15
15
|
let(:client) do
|
16
|
-
double('client', :
|
16
|
+
double('client', post: happy_response, get: happy_response)
|
17
17
|
end
|
18
18
|
|
19
19
|
|
@@ -23,38 +23,38 @@ describe TMS::InstanceResource do
|
|
23
23
|
|
24
24
|
it 'should POST' do
|
25
25
|
@instance_resource.bar = "OMG"
|
26
|
-
@instance_resource.post.
|
26
|
+
expect(@instance_resource.post).to be_truthy
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'should correctly reflect on collection resources' do
|
30
|
-
@instance_resource.blah.class.
|
31
|
-
@instance_resource.shah.class.
|
30
|
+
expect(@instance_resource.blah.class).to eq(GovDelivery::TMS::EmailMessage)
|
31
|
+
expect(@instance_resource.shah.class).to eq(GovDelivery::TMS::EmailMessage)
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'should not GET on initialization' do
|
35
|
-
client.
|
35
|
+
expect(client).not_to receive(:get)
|
36
36
|
Foo.new(client, 'https://example.com/foos/1')
|
37
37
|
end
|
38
38
|
|
39
39
|
it 'should return self on successful get' do
|
40
|
-
client.
|
40
|
+
expect(client).to receive(:get)
|
41
41
|
foo = Foo.new(client, 'https://example.com/foos/1')
|
42
|
-
foo.
|
43
|
-
foo.get.
|
42
|
+
expect(foo).not_to be_new_record
|
43
|
+
expect(foo.get).to eq(foo)
|
44
44
|
end
|
45
45
|
|
46
46
|
%w{get post put delete}.each do |verb|
|
47
47
|
it "should blow up on invalid #{verb}!" do
|
48
|
-
client.
|
48
|
+
expect(client).to(receive(verb)).and_return(double('response', status: 404, body: "{}"))
|
49
49
|
foo = Foo.new(client, 'https://example.com/foos/1')
|
50
50
|
expect do
|
51
51
|
foo.send("#{verb}!")
|
52
|
-
end.to raise_error("TMS::Errors::Invalid#{verb.capitalize}".constantize)
|
52
|
+
end.to raise_error("GovDelivery::TMS::Errors::Invalid#{verb.capitalize}".constantize)
|
53
53
|
end
|
54
54
|
end
|
55
55
|
|
56
56
|
it 'it exposes its attributes hash' do
|
57
|
-
@instance_resource.attributes.
|
57
|
+
expect(@instance_resource.attributes).to eq({})
|
58
58
|
end
|
59
59
|
|
60
60
|
end
|
@@ -1,16 +1,16 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TMS::IpawsAcknowledgement do
|
3
|
+
describe GovDelivery::TMS::IpawsAcknowledgement do
|
4
4
|
|
5
5
|
it 'gets IPAWS acknowledgement from client' do
|
6
6
|
client = double(:client)
|
7
7
|
response_body = { "ACK" => "PONG" }
|
8
|
-
ipaws_acknowledgement = TMS::IpawsAcknowledgement.new(client, '/ipaws/acknowledgement', {})
|
9
|
-
ipaws_acknowledgement.client.
|
10
|
-
double('response', :
|
8
|
+
ipaws_acknowledgement = GovDelivery::TMS::IpawsAcknowledgement.new(client, '/ipaws/acknowledgement', {})
|
9
|
+
expect(ipaws_acknowledgement.client).to receive('get').with(ipaws_acknowledgement.href).and_return(
|
10
|
+
double('response', status: 200, body: response_body)
|
11
11
|
)
|
12
|
-
ipaws_acknowledgement.get.
|
13
|
-
ipaws_acknowledgement.ACK.
|
12
|
+
expect(ipaws_acknowledgement.get).to eq(ipaws_acknowledgement)
|
13
|
+
expect(ipaws_acknowledgement.ACK).to eq("PONG")
|
14
14
|
end
|
15
15
|
|
16
16
|
end
|
data/spec/ipaws_alerts_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TMS::IpawsAlert do
|
3
|
+
describe GovDelivery::TMS::IpawsAlert do
|
4
4
|
|
5
5
|
it 'post new IPAWS alerts to client, and capture status response from IPAWS' do
|
6
6
|
client = double(:client)
|
@@ -97,21 +97,21 @@ describe TMS::IpawsAlert do
|
|
97
97
|
]
|
98
98
|
}
|
99
99
|
|
100
|
-
alerts = TMS::IpawsAlerts.new(client, '/ipaws/alerts')
|
100
|
+
alerts = GovDelivery::TMS::IpawsAlerts.new(client, '/ipaws/alerts')
|
101
101
|
alert = alerts.build(alert_attributes)
|
102
102
|
|
103
|
-
alert.identifier.
|
104
|
-
alert.sender.
|
105
|
-
alert.sent.
|
106
|
-
alert.status.
|
107
|
-
alert.msgType.
|
108
|
-
alert.source.
|
109
|
-
alert.scope.
|
110
|
-
alert.addresses.
|
111
|
-
alert.code.
|
112
|
-
alert.note.
|
113
|
-
alert.incidents.
|
114
|
-
alert.info.
|
103
|
+
expect(alert.identifier).to eq("CAP12-TEST-123")
|
104
|
+
expect(alert.sender).to eq('test@open.com')
|
105
|
+
expect(alert.sent).to eq("2014-04-18T15:02:26-05:00")
|
106
|
+
expect(alert.status).to eq('Actual')
|
107
|
+
expect(alert.msgType).to eq('Alert')
|
108
|
+
expect(alert.source).to eq('IPAWS-TEST')
|
109
|
+
expect(alert.scope).to eq('Public')
|
110
|
+
expect(alert.addresses).to eq('999')
|
111
|
+
expect(alert.code).to eq(['IPAWSv1.0'])
|
112
|
+
expect(alert.note).to eq('test')
|
113
|
+
expect(alert.incidents).to eq('IPAWS-9999')
|
114
|
+
expect(alert.info).to eq([
|
115
115
|
{
|
116
116
|
language: 'en-US',
|
117
117
|
category: ['Safety'],
|
@@ -140,24 +140,24 @@ describe TMS::IpawsAlert do
|
|
140
140
|
}
|
141
141
|
]
|
142
142
|
}
|
143
|
-
]
|
143
|
+
])
|
144
144
|
|
145
|
-
alert.client.
|
146
|
-
alert.post.
|
147
|
-
alert.ipaws_response.
|
145
|
+
expect(alert.client).to receive('post').with(alert).and_return(double('response', status: 200, body: response_body))
|
146
|
+
expect(alert.post).to eq(true)
|
147
|
+
expect(alert.ipaws_response).to eq(response_body)
|
148
148
|
|
149
|
-
alert.identifier.
|
150
|
-
alert.sender.
|
151
|
-
alert.sent.
|
152
|
-
alert.status.
|
153
|
-
alert.msgType.
|
154
|
-
alert.source.
|
155
|
-
alert.scope.
|
156
|
-
alert.addresses.
|
157
|
-
alert.code.
|
158
|
-
alert.note.
|
159
|
-
alert.incidents.
|
160
|
-
alert.info.
|
149
|
+
expect(alert.identifier).to eq("CAP12-TEST-123")
|
150
|
+
expect(alert.sender).to eq('test@open.com')
|
151
|
+
expect(alert.sent).to eq("2014-04-18T15:02:26-05:00")
|
152
|
+
expect(alert.status).to eq('Actual')
|
153
|
+
expect(alert.msgType).to eq('Alert')
|
154
|
+
expect(alert.source).to eq('IPAWS-TEST')
|
155
|
+
expect(alert.scope).to eq('Public')
|
156
|
+
expect(alert.addresses).to eq('999')
|
157
|
+
expect(alert.code).to eq(['IPAWSv1.0'])
|
158
|
+
expect(alert.note).to eq('test')
|
159
|
+
expect(alert.incidents).to eq('IPAWS-9999')
|
160
|
+
expect(alert.info).to eq([
|
161
161
|
{
|
162
162
|
language: 'en-US',
|
163
163
|
category: ['Safety'],
|
@@ -186,7 +186,7 @@ describe TMS::IpawsAlert do
|
|
186
186
|
}
|
187
187
|
]
|
188
188
|
}
|
189
|
-
]
|
189
|
+
])
|
190
190
|
end
|
191
191
|
|
192
192
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TMS::IpawsCogProfile do
|
3
|
+
describe GovDelivery::TMS::IpawsCogProfile do
|
4
4
|
|
5
5
|
it 'gets IPAWS cog profile from client' do
|
6
6
|
client = double(:client)
|
@@ -35,30 +35,30 @@ describe TMS::IpawsCogProfile do
|
|
35
35
|
{"SAME"=>"039035"}
|
36
36
|
]
|
37
37
|
}
|
38
|
-
cog_profile = TMS::IpawsCogProfile.new(client, '/ipaws/cog_profile', {})
|
39
|
-
cog_profile.client.
|
40
|
-
double('response', :
|
38
|
+
cog_profile = GovDelivery::TMS::IpawsCogProfile.new(client, '/ipaws/cog_profile', {})
|
39
|
+
expect(cog_profile.client).to receive('get').with(cog_profile.href).and_return(
|
40
|
+
double('response', status: 200, body: response_body)
|
41
41
|
)
|
42
|
-
cog_profile.get.
|
43
|
-
cog_profile.cogid.
|
42
|
+
expect(cog_profile.get).to eq(cog_profile)
|
43
|
+
expect(cog_profile.cogid).to eq("120082")
|
44
44
|
|
45
|
-
cog_profile.name.
|
46
|
-
cog_profile.description.
|
47
|
-
cog_profile.categoryName.
|
48
|
-
cog_profile.organizationName.
|
49
|
-
cog_profile.cogEnabled.
|
50
|
-
cog_profile.caeAuthorized.
|
51
|
-
cog_profile.caeCmasAuthorized.
|
52
|
-
cog_profile.eanAuthorized.
|
53
|
-
cog_profile.allEventCode.
|
54
|
-
cog_profile.allGeoCode.
|
55
|
-
cog_profile.easAuthorized.
|
56
|
-
cog_profile.cmasAlertAuthorized.
|
57
|
-
cog_profile.cmamTextAuthorized.
|
58
|
-
cog_profile.publicAlertAuthorized.
|
59
|
-
cog_profile.broadcastAuthorized.
|
60
|
-
cog_profile.email.
|
61
|
-
cog_profile.eventCodes.
|
45
|
+
expect(cog_profile.name).to eq("GovDelivery")
|
46
|
+
expect(cog_profile.description).to eq("GovDelivery")
|
47
|
+
expect(cog_profile.categoryName).to eq("IPAWS-OPEN")
|
48
|
+
expect(cog_profile.organizationName).to eq("CIV")
|
49
|
+
expect(cog_profile.cogEnabled).to eq("Y")
|
50
|
+
expect(cog_profile.caeAuthorized).to eq("Y")
|
51
|
+
expect(cog_profile.caeCmasAuthorized).to eq("Y")
|
52
|
+
expect(cog_profile.eanAuthorized).to eq("N")
|
53
|
+
expect(cog_profile.allEventCode).to eq("N")
|
54
|
+
expect(cog_profile.allGeoCode).to eq("N")
|
55
|
+
expect(cog_profile.easAuthorized).to eq("Y")
|
56
|
+
expect(cog_profile.cmasAlertAuthorized).to eq("Y")
|
57
|
+
expect(cog_profile.cmamTextAuthorized).to eq("Y")
|
58
|
+
expect(cog_profile.publicAlertAuthorized).to eq("Y")
|
59
|
+
expect(cog_profile.broadcastAuthorized).to eq("N")
|
60
|
+
expect(cog_profile.email).to eq("joe.bloom@govdelivery.com")
|
61
|
+
expect(cog_profile.eventCodes).to eq([
|
62
62
|
{"ALL"=>"FRW"},
|
63
63
|
{"ALL"=>"SVR"},
|
64
64
|
{"ALL"=>"SPW"},
|
@@ -66,10 +66,10 @@ describe TMS::IpawsCogProfile do
|
|
66
66
|
{"ALL"=>"CAE"},
|
67
67
|
{"ALL"=>"WSW"},
|
68
68
|
{"ALL"=>"CEM"}
|
69
|
-
]
|
70
|
-
cog_profile.geoCodes.
|
69
|
+
])
|
70
|
+
expect(cog_profile.geoCodes).to eq([
|
71
71
|
{"SAME"=>"039035"}
|
72
|
-
]
|
72
|
+
])
|
73
73
|
end
|
74
74
|
|
75
75
|
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
describe TMS::IpawsEventCodes do
|
3
|
+
describe GovDelivery::TMS::IpawsEventCodes do
|
4
4
|
context "loading Ipaws event codes" do
|
5
5
|
let(:client) { double('client') }
|
6
|
-
let(:event_codes) { TMS::IpawsEventCodes.new(client, '/ipaws/event_codes') }
|
6
|
+
let(:event_codes) { GovDelivery::TMS::IpawsEventCodes.new(client, '/ipaws/event_codes') }
|
7
7
|
it 'should GET itself' do
|
8
8
|
body = [
|
9
9
|
{
|
@@ -24,11 +24,11 @@ describe TMS::IpawsEventCodes do
|
|
24
24
|
eas_and_public: true,
|
25
25
|
cmas: false }
|
26
26
|
]
|
27
|
-
client.
|
27
|
+
expect(client).to receive(:get).and_return(double('response', body: body, status: 200, headers: {}))
|
28
28
|
event_codes.get
|
29
|
-
event_codes.collection.length.
|
29
|
+
expect(event_codes.collection.length).to eq(2)
|
30
30
|
event_codes.collection.each do |event_code|
|
31
|
-
event_code.
|
31
|
+
expect(event_code).to be_an_instance_of(GovDelivery::TMS::IpawsEventCode)
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|