mailgun-ruby 1.1.0 → 1.2.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.ruby-env.yml.example +1 -1
- data/.travis.yml +23 -7
- data/Gemfile +2 -0
- data/README.md +79 -18
- data/{Domains.md → docs/Domains.md} +18 -0
- data/{Events.md → docs/Events.md} +0 -0
- data/{MessageBuilder.md → docs/MessageBuilder.md} +32 -13
- data/{Messages.md → docs/Messages.md} +3 -3
- data/{OptInHandler.md → docs/OptInHandler.md} +0 -0
- data/{Snippets.md → docs/Snippets.md} +21 -2
- data/docs/Suppressions.md +82 -0
- data/{Webhooks.md → docs/Webhooks.md} +1 -1
- data/docs/railgun/Overview.md +11 -0
- data/docs/railgun/Parameters.md +83 -0
- data/lib/mailgun/address.rb +48 -0
- data/lib/mailgun/client.rb +85 -8
- data/lib/mailgun/events/events.rb +40 -12
- data/lib/mailgun/exceptions/exceptions.rb +21 -7
- data/lib/mailgun/lists/opt_in_handler.rb +0 -1
- data/lib/mailgun/messages/batch_message.rb +3 -2
- data/lib/mailgun/messages/message_builder.rb +139 -30
- data/lib/mailgun/response.rb +7 -0
- data/lib/mailgun/suppressions.rb +273 -0
- data/lib/mailgun/version.rb +1 -1
- data/lib/mailgun/webhooks/webhooks.rb +1 -1
- data/lib/mailgun-ruby.rb +2 -0
- data/lib/mailgun.rb +1 -0
- data/lib/railgun/attachment.rb +56 -0
- data/lib/railgun/errors.rb +27 -0
- data/lib/railgun/mailer.rb +253 -0
- data/lib/railgun/message.rb +18 -0
- data/lib/railgun/railtie.rb +10 -0
- data/lib/railgun.rb +8 -0
- data/mailgun.gemspec +12 -13
- data/spec/integration/email_validation_spec.rb +57 -15
- data/spec/integration/events_spec.rb +9 -1
- data/spec/integration/mailer_spec.rb +67 -0
- data/spec/integration/mailgun_spec.rb +51 -1
- data/spec/integration/suppressions_spec.rb +142 -0
- data/spec/spec_helper.rb +3 -1
- data/spec/unit/connection/test_client.rb +16 -0
- data/spec/unit/events/events_spec.rb +36 -2
- data/spec/unit/mailgun_spec.rb +32 -10
- data/spec/unit/messages/batch_message_spec.rb +56 -40
- data/spec/unit/messages/message_builder_spec.rb +267 -81
- data/spec/unit/messages/sample_data/unknown.type +0 -0
- data/spec/unit/railgun/content_type_spec.rb +71 -0
- data/spec/unit/railgun/mailer_spec.rb +388 -0
- data/vcr_cassettes/email_validation.yml +136 -25
- data/vcr_cassettes/events.yml +48 -1
- data/vcr_cassettes/exceptions.yml +45 -0
- data/vcr_cassettes/mailer_invalid_domain.yml +109 -0
- data/vcr_cassettes/message_deliver.yml +149 -0
- data/vcr_cassettes/suppressions.yml +727 -0
- metadata +65 -40
@@ -72,60 +72,76 @@ describe 'The method add_recipient' do
|
|
72
72
|
@address_3 = 'sam@example.com'
|
73
73
|
@variables_3 = {'first' => 'Sam', 'last' => 'Doe', 'tracking' => 'GHI123'}
|
74
74
|
end
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
1000.times do
|
79
|
-
@mb_obj.add_recipient(recipient_type, @address_1, @variables_1)
|
75
|
+
context 'when from is present' do
|
76
|
+
before(:each) do
|
77
|
+
@mb_obj.from('example@email.com')
|
80
78
|
end
|
81
79
|
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
end
|
80
|
+
it 'adds 1,000 recipients to the message body and validates counter is incremented then reset' do
|
81
|
+
recipient_type = :to
|
82
|
+
1000.times do
|
83
|
+
@mb_obj.add_recipient(recipient_type, @address_1, @variables_1)
|
84
|
+
end
|
88
85
|
|
89
|
-
|
90
|
-
|
91
|
-
1000.times do
|
86
|
+
expect(@mb_obj.counters[:recipients][recipient_type]).to eq(1000)
|
87
|
+
|
92
88
|
@mb_obj.add_recipient(recipient_type, @address_1, @variables_1)
|
89
|
+
|
90
|
+
expect(@mb_obj.counters[:recipients][recipient_type]).to eq(1)
|
93
91
|
end
|
94
92
|
|
95
|
-
|
96
|
-
|
93
|
+
it 'adds recipients to the message, calls finalize, and cleans up' do
|
94
|
+
recipient_type = :to
|
95
|
+
1000.times do
|
96
|
+
@mb_obj.add_recipient(recipient_type, @address_1, @variables_1)
|
97
|
+
end
|
97
98
|
|
98
|
-
|
99
|
-
|
100
|
-
expect(@mb_obj.counters[:recipients][recipient_type]).to eq(0)
|
101
|
-
end
|
99
|
+
expect(@mb_obj.counters[:recipients][recipient_type]).to eq(1000)
|
100
|
+
@mb_obj.finalize
|
102
101
|
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
@mb_obj.
|
102
|
+
expect(@mb_obj.recipient_variables).to eq({})
|
103
|
+
expect(@mb_obj.message['recipient-variables'].length).to eq(0)
|
104
|
+
expect(@mb_obj.message[:to].length).to eq(0)
|
105
|
+
expect(@mb_obj.counters[:recipients][recipient_type]).to eq(0)
|
107
106
|
end
|
108
|
-
@mb_obj.finalize
|
109
107
|
|
110
|
-
|
111
|
-
|
108
|
+
it 'adds 5,005 recipients to the message body and validates we receive message_ids back' do
|
109
|
+
recipient_type = :to
|
110
|
+
5005.times do
|
111
|
+
@mb_obj.add_recipient(recipient_type, @address_1, @variables_1)
|
112
|
+
end
|
113
|
+
@mb_obj.finalize
|
112
114
|
|
113
|
-
|
114
|
-
|
115
|
-
@mb_obj.add_recipient(recipient_type, @address_1, @variables_1)
|
115
|
+
expect(@mb_obj.message_ids.length).to eq(6)
|
116
|
+
end
|
116
117
|
|
117
|
-
|
118
|
+
it 'sets recipient-variables, for batch expansion' do
|
119
|
+
recipient_type = :to
|
120
|
+
@mb_obj.add_recipient(recipient_type, @address_1, @variables_1)
|
121
|
+
|
122
|
+
expect(@mb_obj.recipient_variables[@address_1]).to eq(@variables_1)
|
123
|
+
end
|
124
|
+
|
125
|
+
it 'sets multiple recipient-variables, for batch expansion' do
|
126
|
+
recipient_type = :to
|
127
|
+
@mb_obj.add_recipient(recipient_type, @address_1, @variables_1)
|
128
|
+
@mb_obj.add_recipient(recipient_type, @address_2, @variables_2)
|
129
|
+
@mb_obj.add_recipient(recipient_type, @address_3, @variables_3)
|
130
|
+
|
131
|
+
expect(@mb_obj.recipient_variables[@address_1]).to eq(@variables_1)
|
132
|
+
expect(@mb_obj.recipient_variables[@address_2]).to eq(@variables_2)
|
133
|
+
expect(@mb_obj.recipient_variables[@address_3]).to eq(@variables_3)
|
134
|
+
end
|
118
135
|
end
|
119
136
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
expect(@mb_obj.recipient_variables[@address_3]).to eq(@variables_3)
|
137
|
+
context 'when from is empty' do
|
138
|
+
it 'shows error message' do
|
139
|
+
recipient_type = :to
|
140
|
+
@mb_obj.add_recipient(recipient_type, @address_1, @variables_1)
|
141
|
+
@mb_obj.add_recipient(recipient_type, @address_2, @variables_2)
|
142
|
+
expect(@mb_client).to receive(:fail)
|
143
|
+
@mb_obj.finalize
|
144
|
+
end
|
129
145
|
end
|
130
146
|
|
131
147
|
end
|