mailgun-ruby 1.4.2 → 1.4.3

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.
Files changed (43) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/ci.yml +30 -8
  3. data/.rubocop.yml +68 -0
  4. data/Gemfile +1 -1
  5. data/README.md +1 -1
  6. data/Rakefile +0 -5
  7. data/lib/mailgun/client.rb +12 -8
  8. data/lib/mailgun/domains/domains.rb +4 -2
  9. data/lib/mailgun/lists/opt_in_handler.rb +2 -4
  10. data/lib/mailgun/messages/batch_message.rb +2 -1
  11. data/lib/mailgun/messages/message_builder.rb +4 -32
  12. data/lib/mailgun/metrics/metrics.rb +6 -2
  13. data/lib/mailgun/response.rb +2 -2
  14. data/lib/mailgun/tags/analytics_tags.rb +9 -5
  15. data/lib/mailgun/tags/tags.rb +4 -2
  16. data/lib/mailgun/version.rb +1 -1
  17. data/lib/railgun/attachment.rb +4 -6
  18. data/lib/railgun/mailer.rb +2 -2
  19. data/mailgun.gemspec +4 -1
  20. data/spec/integration/analytics_tags_spec.rb +1 -1
  21. data/spec/integration/domains_spec.rb +7 -13
  22. data/spec/integration/events_spec.rb +1 -3
  23. data/spec/integration/list_members_spec.rb +1 -1
  24. data/spec/integration/logs_spec.rb +1 -1
  25. data/spec/integration/mailgun_spec.rb +3 -2
  26. data/spec/integration/metrics_spec.rb +9 -3
  27. data/spec/integration/suppressions_spec.rb +203 -26
  28. data/spec/integration/webhook_spec.rb +7 -2
  29. data/spec/spec_helper.rb +7 -0
  30. data/spec/unit/client_spec.rb +424 -0
  31. data/spec/unit/connection/test_client.rb +60 -13
  32. data/spec/unit/events/events_spec.rb +25 -9
  33. data/spec/unit/helpers/api_version_checker_spec.rb +206 -0
  34. data/spec/unit/lists/opt_in_handler_spec.rb +4 -2
  35. data/spec/unit/mailgun_spec.rb +7 -5
  36. data/spec/unit/messages/batch_message_spec.rb +25 -24
  37. data/spec/unit/messages/message_builder_spec.rb +83 -86
  38. data/spec/unit/railgun/content_type_spec.rb +7 -7
  39. data/spec/unit/railgun/mailer_spec.rb +17 -14
  40. data/spec/unit/response_spec.rb +225 -0
  41. data/vcr_cassettes/For_the_suppressions_handling_class/creates_a_single_bounce.yml +55 -0
  42. data/vcr_cassettes/suppressions.yml +1053 -170
  43. metadata +55 -5
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 45aed85ba39b57f41a049e86f7e4aa86e04092c2fc04c86f4a948857cea182c1
4
- data.tar.gz: 4588e70de8bf2836028858adc294e1c1f1b5a8d07de6623a14a1c9797049eecd
3
+ metadata.gz: e4ebcbb3e9a3ff18a06515ffca7027ffa893d0250ad4f6491cd896a78e035428
4
+ data.tar.gz: 27750827e497452d5ea7276601a01621164d9a4decfb3e6f43b1d32c51b7aa62
5
5
  SHA512:
6
- metadata.gz: 346f281a71259601f0215f33a2e7e65d2c76f5f90601522ecf06ff5f9c8c25daff473b1d8a8fc6a71474fdf6ac37c8c89c815831c74b9d1e09238392be139db7
7
- data.tar.gz: 3e00ab15f716a2381735b12a792c6ddc333d32f1574c3d7b50640e293ca4c1f5a60b796c241d3e7c1447cb7b455a162a179c4167d8020bec11f21b6fa03920f1
6
+ metadata.gz: 7432da86b0a9b20ddaea5e0cb049c0fac6b7f8e37cc907d79bbcd5aa642550a8c8067bdd40e3c87f49679306d662906ede13c9bdbb4fd70ea19498f4325c9d92
7
+ data.tar.gz: 8691eac12d6cd590d8735a60965376ee7f751fe700c6533dc61cab987917292ef21d03e22d0c35c2c58584288602396b5201b8d5b55bdf9834693819a10185cc
@@ -11,17 +11,39 @@ permissions:
11
11
 
12
12
  jobs:
13
13
  test:
14
+ permissions: write-all
14
15
  runs-on: ubuntu-latest
15
16
  strategy:
16
17
  matrix:
17
18
  ruby-version: [ '3.0', '3.1', '3.2', '3.3', '3.4', '4.0' ]
18
19
 
19
20
  steps:
20
- - uses: actions/checkout@v6
21
- - name: Set up Ruby
22
- uses: ruby/setup-ruby@v1
23
- with:
24
- ruby-version: ${{ matrix.ruby-version }}
25
- bundler-cache: true
26
- - name: Run tests
27
- run: bundle exec rake spec:all
21
+ - uses: actions/checkout@v6
22
+ - name: Set up Ruby
23
+ uses: ruby/setup-ruby@v1
24
+ with:
25
+ ruby-version: ${{ matrix.ruby-version }}
26
+ bundler-cache: true
27
+ - name: Run tests
28
+ run: bundle exec rake spec:all
29
+ - uses: joshmfrankel/simplecov-check-action@main
30
+ with:
31
+ minimum_suite_coverage: 95
32
+ minimum_file_coverage: 80
33
+ github_token: ${{ secrets.GITHUB_TOKEN }}
34
+ if: matrix.ruby-version == '4.0'
35
+
36
+ rubocop:
37
+ permissions: write-all
38
+ runs-on: ubuntu-latest
39
+
40
+ steps:
41
+ - uses: actions/checkout@v6
42
+ - name: Set up Ruby
43
+ uses: ruby/setup-ruby@v1
44
+ with:
45
+ ruby-version: '4.0'
46
+ bundler-cache: true
47
+ - name: Run rubocop
48
+ run: |
49
+ bundle exec rubocop --format github
data/.rubocop.yml ADDED
@@ -0,0 +1,68 @@
1
+ AllCops:
2
+ NewCops: disable
3
+ SuggestExtensions: false
4
+
5
+ plugins:
6
+ - rubocop-rspec
7
+ - rubocop-rake
8
+
9
+ # temporary disable main codebase errors
10
+ Metrics/MethodLength:
11
+ Enabled: false
12
+ Metrics/BlockLength:
13
+ Enabled: false
14
+ Metrics/ClassLength:
15
+ Enabled: false
16
+ Metrics/CyclomaticComplexity:
17
+ Enabled: false
18
+ Metrics/PerceivedComplexity:
19
+ Enabled: false
20
+ Metrics/AbcSize:
21
+ Enabled: false
22
+ Metrics/ParameterLists:
23
+ Enabled: false
24
+ Lint/MissingSuper:
25
+ Enabled: false
26
+ Style/Documentation:
27
+ Enabled: false
28
+ Style/OptionalBooleanParameter:
29
+ Enabled: false
30
+ Naming/FileName:
31
+ Exclude:
32
+ - 'lib/mailgun-ruby.rb'
33
+
34
+ # temporary disable rspec errors
35
+ RSpec/MultipleExpectations:
36
+ Enabled: false
37
+ RSpec/ExampleLength:
38
+ Enabled: false
39
+ RSpec/InstanceVariable:
40
+ Enabled: false
41
+ RSpec/MultipleMemoizedHelpers:
42
+ Enabled: false
43
+ RSpec/StubbedMock:
44
+ Enabled: false
45
+ RSpec/AnyInstance:
46
+ Enabled: false
47
+ RSpec/MessageSpies:
48
+ Enabled: false
49
+ RSpec/DescribeClass:
50
+ Enabled: false
51
+ RSpec/VerifiedDoubles:
52
+ Enabled: false
53
+ RSpec/NoExpectationExample:
54
+ Enabled: false
55
+ RSpec/RepeatedDescription:
56
+ Enabled: false
57
+ RSpec/NestedGroups:
58
+ Enabled: false
59
+ RSpec/MultipleDescribes:
60
+ Enabled: false
61
+ RSpec/BeforeAfterAll:
62
+ Enabled: false
63
+ RSpec/SpecFilePathFormat:
64
+ Enabled: false
65
+ RSpec/ContextWording:
66
+ Enabled: false
67
+ RSpec/OverwritingSetup:
68
+ Enabled: false
data/Gemfile CHANGED
@@ -5,5 +5,5 @@ source 'https://rubygems.org'
5
5
  # Specify your gem's dependencies in mailgun.gemspec
6
6
  gemspec
7
7
 
8
- gem 'json', '~> 2.1', platform: :mri_19
8
+ gem 'json', '~> 2.1'
9
9
  gem 'mini_mime'
data/README.md CHANGED
@@ -19,7 +19,7 @@ gem install mailgun-ruby
19
19
  Gemfile:
20
20
 
21
21
  ```ruby
22
- gem 'mailgun-ruby', '~>1.4.2'
22
+ gem 'mailgun-ruby', '~>1.4.3'
23
23
  ```
24
24
 
25
25
  Usage
data/Rakefile CHANGED
@@ -30,8 +30,3 @@ RSpec::Core::RakeTask.new('spec:all') do |t|
30
30
  end
31
31
 
32
32
  task default: 'spec:unit'
33
- task spec: 'spec:unit'
34
-
35
- task :console do
36
- sh 'pry --gem'
37
- end
@@ -50,14 +50,18 @@ module Mailgun
50
50
  end
51
51
 
52
52
  # Change API key
53
+ # rubocop:disable Naming/AccessorMethodName
53
54
  def set_api_key(api_key)
54
55
  @http_client.set_basic_auth('api', api_key)
55
56
  end
57
+ # rubocop:enable Naming/AccessorMethodName
56
58
 
57
59
  # Add subaccount id to headers
60
+ # rubocop:disable Naming/AccessorMethodName
58
61
  def set_subaccount(subaccount_id)
59
62
  @http_client.headers.merge!({ SUBACCOUNT_HEADER => subaccount_id })
60
63
  end
64
+ # rubocop:enable Naming/AccessorMethodName
61
65
 
62
66
  # Reset subaccount for primary usage
63
67
  def reset_subaccount
@@ -78,7 +82,7 @@ module Mailgun
78
82
  #
79
83
  # @return [Hash]
80
84
  def self.deliveries
81
- @@deliveries ||= []
85
+ @deliveries ||= []
82
86
  end
83
87
 
84
88
  # Simple Message Sending
@@ -231,18 +235,18 @@ module Mailgun
231
235
  # Raises CommunicationError and stores response in it if present
232
236
  #
233
237
  # @param [StandardException] e upstream exception object
234
- def communication_error(e)
235
- if e.respond_to?(:response) && e.response
236
- return case e.response_status
238
+ def communication_error(error)
239
+ if error.respond_to?(:response) && error.response
240
+ return case error.response_status
237
241
  when Unauthorized::CODE
238
- Unauthorized.new(e.message, e.response)
242
+ Unauthorized.new(error.message, error.response)
239
243
  when BadRequest::CODE
240
- BadRequest.new(e.message, e.response)
244
+ BadRequest.new(error.message, error.response)
241
245
  else
242
- CommunicationError.new(e.message, e.response)
246
+ CommunicationError.new(error.message, error.response)
243
247
  end
244
248
  end
245
- CommunicationError.new(e.message)
249
+ CommunicationError.new(error.message)
246
250
  end
247
251
 
248
252
  def perform_data_validation(working_domain, data)
@@ -197,7 +197,8 @@ module Mailgun
197
197
  #
198
198
  # domain - [String] Name of the domain (ex. domain.com)
199
199
  # options - [Hash] of
200
- # active - [Boolean] yes or no. If set to yes, links will be overwritten and pointed to our servers so we can track clicks.
200
+ # active - [Boolean] yes or no. If set to yes, links will be overwritten and pointed to our servers
201
+ # so we can track clicks.
201
202
  #
202
203
  # Returns [Hash] Information on the tracking click settings
203
204
  def update_domain_tracking_click_settings(domain, options = {})
@@ -209,7 +210,8 @@ module Mailgun
209
210
  # domain - [String] Name of the domain (ex. domain.com)
210
211
  # options - [Hash] of
211
212
  # active - [Boolean] yes or no. If set to yes, a tracking pixel will be inserted below your HTML content.
212
- # place_at_the_top - [Boolean] yes or no. If set to yes, tracking pixel will be moved to top of your HTML content.
213
+ # place_at_the_top - [Boolean] yes or no. If set to yes, tracking pixel will be moved
214
+ # to top of your HTML content.
213
215
  #
214
216
  # Returns [Hash] Information on the tracking open settings
215
217
  def update_domain_tracking_open_settings(domain, options = {})
@@ -32,7 +32,8 @@ module Mailgun
32
32
  #
33
33
  # @param [String] secret_app_id A secret passphrase used as a constant for the hash.
34
34
  # @param [Hash] unique_hash The hash from the user. Likely via link click.
35
- # @return [Hash or Boolean] A hash with 'recipient_address' and 'mailing_list', if validates. Otherwise, boolean false.
35
+ # @return [Hash or Boolean] A hash with 'recipient_address' and 'mailing_list', if validates.
36
+ # Otherwise, boolean false.
36
37
  def self.validate_hash(secret_app_id, unique_hash)
37
38
  outer_payload = JSON.parse(base64_decode(CGI.unescape(unique_hash)))
38
39
 
@@ -57,9 +58,6 @@ module Mailgun
57
58
 
58
59
  # Equivalent to Base64.decode64
59
60
  def self.base64_decode(input)
60
- # TODO: Condition can be droped if Ruby >= 2.4.0
61
- if input.respond_to?(:unpack1)
62
- end
63
61
  input.unpack1('m')
64
62
  end
65
63
 
@@ -39,7 +39,8 @@ module Mailgun
39
39
  #
40
40
  # @param [String] recipient_type The type of recipient. "to".
41
41
  # @param [String] address The email address of the recipient to add to the message object.
42
- # @param [Hash] variables A hash of the variables associated with the recipient. We recommend "first" and "last" at a minimum!
42
+ # @param [Hash] variables A hash of the variables associated with the recipient.
43
+ # We recommend "first" and "last" at a minimum!
43
44
  # @return [void]
44
45
  def add_recipient(recipient_type, address, variables = nil)
45
46
  # send the message when we have 1000, not before
@@ -25,7 +25,8 @@ module Mailgun
25
25
  #
26
26
  # @param [String] recipient_type The type of recipient. "to", "cc", "bcc" or "h:reply-to".
27
27
  # @param [String] address The email address of the recipient to add to the message object.
28
- # @param [Hash] variables A hash of the variables associated with the recipient. We recommend "first" and "last" at a minimum!
28
+ # @param [Hash] variables A hash of the variables associated with the recipient.
29
+ # We recommend "first" and "last" at a minimum!
29
30
  # @return [void]
30
31
  def add_recipient(recipient_type, address, variables = nil)
31
32
  if recipient_type == 'h:reply-to'
@@ -46,7 +47,8 @@ module Mailgun
46
47
  # Sets the from address for the message
47
48
  #
48
49
  # @param [String] address The address of the sender.
49
- # @param [Hash] variables A hash of the variables associated with the recipient. We recommend "first" and "last" at a minimum!
50
+ # @param [Hash] variables A hash of the variables associated with the recipient.
51
+ # We recommend "first" and "last" at a minimum!
50
52
  # @return [void]
51
53
  def from(address, vars = nil)
52
54
  add_recipient(:from, address, vars)
@@ -155,12 +157,6 @@ module Mailgun
155
157
  set_multi_simple('o:testmode', bool_lookup(mode))
156
158
  end
157
159
 
158
- # Deprecated: 'set_test_mode' is depreciated. Please use 'test_mode' instead.
159
- def set_test_mode(mode)
160
- warn 'DEPRECATION: "set_test_mode" is deprecated. Please use "test_mode" instead.'
161
- test_mode(mode)
162
- end
163
-
164
160
  # Turn DKIM on or off per message
165
161
  #
166
162
  # @param [Boolean] mode The boolean or string value(will fix itself)
@@ -169,12 +165,6 @@ module Mailgun
169
165
  set_multi_simple('o:dkim', bool_lookup(mode))
170
166
  end
171
167
 
172
- # Deprecated: 'set_dkim' is deprecated. Please use 'dkim' instead.
173
- def set_dkim(mode)
174
- warn 'DEPRECATION: "set_dkim" is deprecated. Please use "dkim" instead.'
175
- dkim(mode)
176
- end
177
-
178
168
  # Add campaign IDs to message. Limit of 3 per message.
179
169
  #
180
170
  # @param [String] campaign_id A defined campaign ID to add to the message.
@@ -212,12 +202,6 @@ module Mailgun
212
202
  set_multi_simple('o:tracking', value)
213
203
  end
214
204
 
215
- # Deprecated: 'set_open_tracking' is deprecated. Please use 'track_opens' instead.
216
- def set_open_tracking(tracking)
217
- warn 'DEPRECATION: "set_open_tracking" is deprecated. Please use "track_opens" instead.'
218
- track_opens(tracking)
219
- end
220
-
221
205
  # Turn Click Tracking on and off, on a per message basis.
222
206
  #
223
207
  # @param [String] mode True, False, or HTML (for HTML only tracking)
@@ -228,12 +212,6 @@ module Mailgun
228
212
  set_multi_simple('o:tracking', value)
229
213
  end
230
214
 
231
- # Depreciated: 'set_click_tracking. is deprecated. Please use 'track_clicks' instead.
232
- def set_click_tracking(tracking)
233
- warn 'DEPRECATION: "set_click_tracking" is deprecated. Please use "track_clicks" instead.'
234
- track_clicks(tracking)
235
- end
236
-
237
215
  # Enable Delivery delay on message. Specify an RFC2822 date, and Mailgun
238
216
  # will not deliver the message until that date/time. For conversion
239
217
  # options, see Ruby "Time". Example: "October 25, 2013 10:00PM CST" will
@@ -246,12 +224,6 @@ module Mailgun
246
224
  set_multi_simple('o:deliverytime', time_str.rfc2822)
247
225
  end
248
226
 
249
- # Deprecated: 'set_delivery_time' is deprecated. Please use 'deliver_at' instead.
250
- def set_delivery_time(timestamp)
251
- warn 'DEPRECATION: "set_delivery_time" is deprecated. Please use "deliver_at" instead.'
252
- deliver_at timestamp
253
- end
254
-
255
227
  # Add custom data to the message. The data should be either a hash or JSON
256
228
  # encoded. The custom data will be added as a header to your message.
257
229
  #
@@ -16,7 +16,9 @@ module Mailgun
16
16
  # start - [String] A start date (default: 7 days before current time). Must be in RFC 2822 format.
17
17
  # end - [String] An end date (default: current time). Must be in RFC 2822 format.
18
18
  # resolution - [String] A resolution in the format of 'day' 'hour' 'month'. Default is day.
19
- # duration - [String] A duration in the format of '1d' '2h' '2m'. If duration is provided then it is calculated from the end date and overwrites the start date.
19
+ # duration - [String] A duration in the format of '1d' '2h' '2m'.
20
+ # If duration is provided then it is calculated from the end date
21
+ # and overwrites the start date.
20
22
  # dimensions - [Array] Attributes of the metric data such as 'subaccount'.
21
23
  # metrics - [Array] Name of the metrics to receive the stats for such as 'processed_count'
22
24
  # filter - [Object]
@@ -40,7 +42,9 @@ module Mailgun
40
42
  # start - [String] A start date (default: 7 days before current time). Must be in RFC 2822 format.
41
43
  # end - [String] An end date (default: current time). Must be in RFC 2822 format.
42
44
  # resolution - [String] A resolution in the format of 'day' 'hour' 'month'. Default is day.
43
- # duration - [String] A duration in the format of '1d' '2h' '2m'. If duration is provided then it is calculated from the end date and overwrites the start date.
45
+ # duration - [String] A duration in the format of '1d' '2h' '2m'.
46
+ # If duration is provided then it is calculated from the end date and
47
+ # overwrites the start date.
44
48
  # dimensions - [Array] Attributes of the metric data such as 'subaccount'.
45
49
  # metrics - [Array] Name of the metrics to receive the stats for such as 'processed_count'
46
50
  # filter - [Object]
@@ -13,9 +13,9 @@ module Mailgun
13
13
  attr_accessor :body, :status, :code
14
14
 
15
15
  ResponseHash = Struct.new(:body, :status)
16
- def self.from_hash(h)
16
+ def self.from_hash(hash)
17
17
  # Create a "fake" response object with the data passed from h
18
- new ResponseHash.new(h[:body], h[:status])
18
+ new ResponseHash.new(hash[:body], hash[:status])
19
19
  end
20
20
 
21
21
  def initialize(response)
@@ -26,15 +26,19 @@ module Mailgun
26
26
  # Public: Post query to list account tags or search for single tag
27
27
  #
28
28
  # options - [Hash] of
29
- # include_subaccounts - [Boolean] Boolean indicating whether or not to include data from all subaccounts. Default false.
30
- # include_metrics - [Boolean] Boolean indicating whether or not to include metrics for tags. Default false. When true max limit is 20.
31
- # tag - [string] The tag or tag prefix.
29
+ # include_subaccounts - [Boolean] Boolean indicating whether or not to include data from all subaccounts.
30
+ # Default false.
31
+ # include_metrics - [Boolean] Boolean indicating whether or not to include metrics for tags.
32
+ # Default false. When true max limit is 20.
33
+ # tag - [String] The tag or tag prefix.
32
34
  # pagination - [Object]
33
- # sort - [String] Colon-separated value indicating column name and sort direction e.g. 'timestamp:desc'.
35
+ # sort - [String] Colon-separated value indicating column name and sort direction
36
+ # e.g. 'timestamp:desc'.
34
37
  # skip - [Integer] The number of items to skip over when satisfying the request.
35
38
  # limit - [Integer] The maximum number of items returned (100 max).
36
39
  # total - [Integer] The total number of tags matching the search criteria.
37
- # include_total - [Boolean] Boolean indicating whether or not to include total number of items. Default false.
40
+ # include_total - [Boolean] Boolean indicating whether or not to include total number of items.
41
+ # Default false.
38
42
 
39
43
  #
40
44
  # Returns [Hash] Information on the requested tags.
@@ -63,10 +63,12 @@ module Mailgun
63
63
  # tag - [String] Tag name to lookup for
64
64
  # options - [Hash] of
65
65
  # event - [String] The type of the event. Required. (ex. accepted, delivered, failed, opened)
66
- # start - [String] The starting time. Should be in RFC 282 or unix epoch format. Default: 7 days from the current time.
66
+ # start - [String] The starting time. Should be in RFC 282 or unix epoch format.
67
+ # Default: 7 days from the current time.
67
68
  # end - [String] The ending date. Should be in RFC 2822 or unix epoch time in seconds. Default: current time.
68
69
  # resolution - [String] Can be either hour, day or month. Default: day
69
- # duration - [String] Period of time with resolution encoded. If provided, overwrites the start date and resolution.
70
+ # duration - [String] Period of time with resolution encoded.
71
+ # If provided, overwrites the start date and resolution.
70
72
  #
71
73
  # Returns [Hash] of tag stats info
72
74
  def get_tag_stats(domain, tag, options = {})
@@ -2,5 +2,5 @@
2
2
 
3
3
  # It's the version. Yeay!
4
4
  module Mailgun
5
- VERSION = '1.4.2'
5
+ VERSION = '1.4.3'
6
6
  end
@@ -30,7 +30,7 @@ module Railgun
30
30
  @inline
31
31
  end
32
32
 
33
- def is_original_filename
33
+ def original_filename?
34
34
  @original_filename == @overwritten_filename
35
35
  end
36
36
 
@@ -38,13 +38,11 @@ module Railgun
38
38
  @filename
39
39
  end
40
40
 
41
- def attach_to_message!(mb)
42
- nil if mb.nil?
43
-
41
+ def attach_to_message!(m_body)
44
42
  if inline?
45
- mb.add_inline_image self, @filename
43
+ m_body.add_inline_image self, @filename
46
44
  else
47
- mb.add_attachment self, @filename
45
+ m_body.add_attachment self, @filename
48
46
  end
49
47
  end
50
48
  end
@@ -41,7 +41,7 @@ module Railgun
41
41
  end
42
42
 
43
43
  def deliver!(mail)
44
- @mg_domain = set_mg_domain(mail)
44
+ @mg_domain = mg_domain(mail)
45
45
  @mg_client.set_api_key(mail[:api_key].value) if mail[:api_key].present?
46
46
  @mg_client.set_subaccount(mail[:subaccount_id].value) if mail[:subaccount_id].present?
47
47
 
@@ -66,7 +66,7 @@ module Railgun
66
66
  private
67
67
 
68
68
  # Set @mg_domain from mail[:domain] header if present, then remove it to prevent being sent.
69
- def set_mg_domain(mail)
69
+ def mg_domain(mail)
70
70
  return mail[:domain].value if mail[:domain]
71
71
 
72
72
  domain
data/mailgun.gemspec CHANGED
@@ -34,7 +34,10 @@ Gem::Specification.new do |spec|
34
34
  spec.add_development_dependency 'rspec', '~> 3.13.0'
35
35
  spec.add_development_dependency 'rspec-its', '~> 2.0.0'
36
36
  spec.add_development_dependency 'rubocop'
37
- spec.add_development_dependency 'simplecov', '~> 0.16.1'
37
+ spec.add_development_dependency 'rubocop-rake'
38
+ spec.add_development_dependency 'rubocop-rspec'
39
+ spec.add_development_dependency 'simplecov'
40
+ spec.add_development_dependency 'simplecov-json'
38
41
  spec.add_development_dependency 'vcr', '~> 6.4.0'
39
42
  spec.add_development_dependency 'webmock', '~> 3.7'
40
43
  spec.add_dependency 'faraday', '~> 2.1'
@@ -44,7 +44,7 @@ describe 'AnalyticsTags', vcr: vcr_opts do
44
44
  end
45
45
  end
46
46
 
47
- context '#limits' do
47
+ describe '#limits' do
48
48
  it 'returns limits' do
49
49
  response = mg_obj.limits
50
50
 
@@ -44,7 +44,7 @@ describe 'For the domains endpoint', vcr: vcr_opts do
44
44
  end
45
45
  end
46
46
 
47
- context '#update' do
47
+ describe '#update' do
48
48
  let(:api_version) { 'v4' }
49
49
 
50
50
  it 'updates the domain' do
@@ -52,11 +52,11 @@ describe 'For the domains endpoint', vcr: vcr_opts do
52
52
 
53
53
  expect(response['domain']['spam_action']).to eq('block')
54
54
  expect(response['domain']['web_scheme']).to eq('https')
55
- expect(response['domain']['wildcard']).to eq(true)
55
+ expect(response['domain']['wildcard']).to be(true)
56
56
  end
57
57
  end
58
58
 
59
- context '#verify' do
59
+ describe '#verify' do
60
60
  let(:api_version) { 'v4' }
61
61
 
62
62
  it 'verifies the domain' do
@@ -199,7 +199,7 @@ describe 'For the domains endpoint', vcr: vcr_opts do
199
199
  )
200
200
 
201
201
  expect(result).to include('tracking')
202
- expect(result['tracking']['click']['active']).to eq(false)
202
+ expect(result['tracking']['click']['active']).to be(false)
203
203
  end
204
204
  end
205
205
 
@@ -212,7 +212,7 @@ describe 'For the domains endpoint', vcr: vcr_opts do
212
212
  }
213
213
  )
214
214
 
215
- expect(result['click']['active']).to eq(false)
215
+ expect(result['click']['active']).to be(false)
216
216
  end
217
217
  end
218
218
 
@@ -225,7 +225,7 @@ describe 'For the domains endpoint', vcr: vcr_opts do
225
225
  }
226
226
  )
227
227
 
228
- expect(result['open']['active']).to eq(false)
228
+ expect(result['open']['active']).to be(false)
229
229
  end
230
230
  end
231
231
 
@@ -238,17 +238,11 @@ describe 'For the domains endpoint', vcr: vcr_opts do
238
238
  }
239
239
  )
240
240
 
241
- expect(result['unsubscribe']['active']).to eq(false)
241
+ expect(result['unsubscribe']['active']).to be(false)
242
242
  end
243
243
  end
244
244
  end
245
245
 
246
- context 'Domain::DKIM_Security methods' do
247
- # TODO: add missing:
248
- # dkim_rotation
249
- # dkim_rotate
250
- end
251
-
252
246
  context 'Credentials methods' do
253
247
  # TODO: to be moved to the dedicated module
254
248
 
@@ -23,8 +23,6 @@ describe 'For the Events endpoint', vcr: vcr_opts do
23
23
  end
24
24
 
25
25
  it 'can iterate over all events with `each`' do
26
- @events.each do |e|
27
- expect(e).to have_key('event')
28
- end
26
+ expect(@events).to all(have_key('event'))
29
27
  end
30
28
  end
@@ -54,7 +54,7 @@ describe 'For the Mailing Lists Members endpoint', order: :defined, vcr: vcr_opt
54
54
  expect(result.body['message']).to eq('Mailing list member has been updated')
55
55
  expect(result.body['member']['address']).to eq(@ml_member)
56
56
  expect(result.body['member']['name']).to eq('Jane Doe Update')
57
- expect(result.body['member']['subscribed']).to eq(false)
57
+ expect(result.body['member']['subscribed']).to be(false)
58
58
  end
59
59
 
60
60
  it 'removes a list member' do
@@ -6,7 +6,7 @@ require 'mailgun'
6
6
  vcr_opts = { cassette_name: 'logs' }
7
7
 
8
8
  describe Mailgun::Logs, vcr: vcr_opts do
9
- let(:logs) { Mailgun::Logs.new(Mailgun::Client.new(APIKEY, APIHOST, 'v1')) }
9
+ let(:logs) { described_class.new(Mailgun::Client.new(APIKEY, APIHOST, 'v1')) }
10
10
 
11
11
  describe '#account_logs' do
12
12
  let(:options) do
@@ -109,12 +109,13 @@ describe 'The method send_message()', vcr: { cassette_name: 'send_message' } do
109
109
  result.to_h!
110
110
  expect(result.body).to include('message')
111
111
  expect(result.body).to include('id')
112
+ expect(Mailgun::Client.deliveries.size).to eq(1)
112
113
  end
113
114
 
114
115
  it 'fakes message send while in *client* test mode' do
115
116
  @mg_obj.enable_test_mode!
116
117
 
117
- expect(@mg_obj.test_mode?).to eq(true)
118
+ expect(@mg_obj.test_mode?).to be(true)
118
119
 
119
120
  data = { from: "joe@#{@domain}",
120
121
  to: "bob@#{@domain}",
@@ -182,7 +183,7 @@ Testing some Mailgun awesomness!'
182
183
  it 'receives success response code' do
183
184
  @mg_obj.enable_test_mode!
184
185
 
185
- expect(@mg_obj.test_mode?).to eq(true)
186
+ expect(@mg_obj.test_mode?).to be(true)
186
187
 
187
188
  data = { from: "joe@#{@domain}",
188
189
  to: "bob@#{@domain}",
@@ -6,7 +6,7 @@ require 'mailgun'
6
6
  vcr_opts = { cassette_name: 'metrics' }
7
7
 
8
8
  describe Mailgun::Metrics, vcr: vcr_opts do
9
- let(:metrics) { Mailgun::Metrics.new(Mailgun::Client.new(APIKEY, APIHOST, 'v1')) }
9
+ let(:metrics) { described_class.new(Mailgun::Client.new(APIKEY, APIHOST, 'v1')) }
10
10
 
11
11
  describe '#account_metrics' do
12
12
  let(:options) do
@@ -69,7 +69,10 @@ describe Mailgun::Metrics, vcr: vcr_opts do
69
69
  'display_value' => 'Wed, 27 Nov 2024 13:00:00 +0000'
70
70
  }],
71
71
  'metrics' => {
72
- 'accepted_count' => 1, 'delivered_count' => 1, 'opened_rate' => '0.0000', 'clicked_rate' => '0.0000'
72
+ 'accepted_count' => 1,
73
+ 'delivered_count' => 1,
74
+ 'opened_rate' => '0.0000',
75
+ 'clicked_rate' => '0.0000'
73
76
  }
74
77
  },
75
78
  {
@@ -79,7 +82,10 @@ describe Mailgun::Metrics, vcr: vcr_opts do
79
82
  'display_value' => 'Thu, 28 Nov 2024 15:00:00 +0000'
80
83
  }],
81
84
  'metrics' => {
82
- 'accepted_count' => 1, 'delivered_count' => 1, 'opened_rate' => '0.0000', 'clicked_rate' => '0.0000'
85
+ 'accepted_count' => 1,
86
+ 'delivered_count' => 1,
87
+ 'opened_rate' => '0.0000',
88
+ 'clicked_rate' => '0.0000'
83
89
  }
84
90
  }],
85
91
  'aggregates' => {