ahoy_email 0.3.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 49c170ba212ecf55a91229da66bd709ae46845d3
4
- data.tar.gz: 5c63a301d6ec6cb0d2f711a0398b3d0655eb2262
3
+ metadata.gz: 98b36aef95156ff7e1938250d562849b11099b18
4
+ data.tar.gz: 9b268aac653efb5427ccf133dabbd37418d3815a
5
5
  SHA512:
6
- metadata.gz: 5be291db638905583b8417f1a402083ae5c3d675b76acdc7a1115400510e2b9685ecbdea94d5ce6952daba528d4fff98e69650d95408e435aff6358ebe666439
7
- data.tar.gz: 1f39a60bc2ec8a69c3584b0cbaa2888e5e055272d973f448aefa49dc7bb70d2c653dabccc15a7fdea01fed5cf493bba8b8f215918886acd6889d2a45fcb57a90
6
+ metadata.gz: 126c5fd727f97a61f9a84e99ba8a4fa12b587dc76ba4d21ad1d998ff57bc3f93f963292053b5fad70b4c4a0b90be0017c6978a7a63de3ef7c8ce15504221211b
7
+ data.tar.gz: 979d1310f3b909296202075e000ec7ca3f3ca8e409934534919ced80bc14dc9b5673219acd862c53fedaeba82c0dd2789d29f8a929e951c8f5ec94db16c63e14
data/.gitignore CHANGED
@@ -3,7 +3,7 @@
3
3
  .bundle
4
4
  .config
5
5
  .yardoc
6
- Gemfile.lock
6
+ *.lock
7
7
  InstalledFiles
8
8
  _yardoc
9
9
  coverage
data/CHANGELOG.md CHANGED
@@ -1,3 +1,8 @@
1
+ ## 0.3.1
2
+
3
+ - Fixed deprecation warnings
4
+ - Fixed `stack level too deep` error
5
+
1
6
  ## 0.3.0
2
7
 
3
8
  - Added safely for error reporting
@@ -20,7 +20,7 @@ module Ahoy
20
20
  url = params[:url].to_s
21
21
  signature = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), AhoyEmail.secret_token, url)
22
22
  publish :click, url: params[:url]
23
- if secure_compare(params[:signature], signature)
23
+ if secure_compare(params[:signature].to_s, signature)
24
24
  redirect_to url
25
25
  else
26
26
  redirect_to main_app.root_url
data/config/routes.rb CHANGED
@@ -1,5 +1,7 @@
1
1
  Rails.application.routes.draw do
2
- mount AhoyEmail::Engine => "/ahoy"
2
+ unless respond_to?(:has_named_route?) && has_named_route?("ahoy_email_engine")
3
+ mount AhoyEmail::Engine => "/ahoy"
4
+ end
3
5
  end
4
6
 
5
7
  AhoyEmail::Engine.routes.draw do
@@ -2,11 +2,11 @@ module AhoyEmail
2
2
  module Mailer
3
3
  def self.included(base)
4
4
  base.extend ClassMethods
5
+ base.prepend InstanceMethods
5
6
  base.class_eval do
6
7
  attr_accessor :ahoy_options
7
8
  class_attribute :ahoy_options
8
9
  self.ahoy_options = {}
9
- alias_method_chain :mail, :ahoy
10
10
  end
11
11
  end
12
12
 
@@ -16,17 +16,19 @@ module AhoyEmail
16
16
  end
17
17
  end
18
18
 
19
- def track(options = {})
20
- self.ahoy_options = (ahoy_options || {}).merge(message: true).merge(options)
21
- end
19
+ module InstanceMethods
20
+ def track(options = {})
21
+ self.ahoy_options = (ahoy_options || {}).merge(message: true).merge(options)
22
+ end
22
23
 
23
- def mail_with_ahoy(headers = {}, &block)
24
- # this mimics what original method does
25
- return message if @_mail_was_called && headers.blank? && !block
24
+ def mail(headers = {}, &block)
25
+ # this mimics what original method does
26
+ return message if @_mail_was_called && headers.blank? && !block
26
27
 
27
- message = mail_without_ahoy(headers, &block)
28
- AhoyEmail::Processor.new(message, self).process
29
- message
28
+ message = super
29
+ AhoyEmail::Processor.new(message, self).process
30
+ message
31
+ end
30
32
  end
31
33
  end
32
34
  end
@@ -39,7 +39,7 @@ module AhoyEmail
39
39
 
40
40
  def track_send
41
41
  safely do
42
- if (message_id = message["Ahoy-Message-Id"])
42
+ if (message_id = message["Ahoy-Message-Id"]) && message.perform_deliveries
43
43
  ahoy_message = AhoyEmail.message_model.where(id: message_id.to_s).first
44
44
  if ahoy_message
45
45
  ahoy_message.sent_at = Time.now
@@ -1,3 +1,3 @@
1
1
  module AhoyEmail
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ahoy_email.gemspec
4
+ gemspec path: "../../"
5
+
6
+ gem "actionmailer", "~> 3.2.0"
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ahoy_email.gemspec
4
+ gemspec path: "../../"
5
+
6
+ gem "actionmailer", "~> 4.0.0"
@@ -0,0 +1,6 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in ahoy_email.gemspec
4
+ gemspec path: "../../"
5
+
6
+ gem "actionmailer", "~> 4.1.0"
data/test/mailer_test.rb CHANGED
@@ -1,7 +1,8 @@
1
1
  require_relative "test_helper"
2
2
 
3
3
  class UserMailer < ActionMailer::Base
4
- after_action :prevent_delivery_to_guests, only: [:welcome2]
4
+ default from: "from@example.com"
5
+ after_action :prevent_delivery_to_guests, only: [:welcome2] if Rails.version >= "4.0.0"
5
6
 
6
7
  def welcome
7
8
  mail to: "test@example.org", subject: "Hello", body: "World"
@@ -11,6 +12,11 @@ class UserMailer < ActionMailer::Base
11
12
  mail to: "test@example.org", subject: "Hello", body: "World"
12
13
  end
13
14
 
15
+ def welcome3
16
+ track message: false
17
+ mail to: "test@example.org", subject: "Hello", body: "World"
18
+ end
19
+
14
20
  private
15
21
 
16
22
  def prevent_delivery_to_guests
@@ -29,11 +35,19 @@ class MailerTest < Minitest::Test
29
35
 
30
36
  def test_prevent_delivery
31
37
  assert_message :welcome2
38
+ if Rails.version >= "4.0.0"
39
+ assert_nil Ahoy::Message.first.sent_at
40
+ end
41
+ end
42
+
43
+ def test_no_message
44
+ UserMailer.welcome3.to
45
+ assert_equal 0, Ahoy::Message.count
32
46
  end
33
47
 
34
48
  def assert_message(method)
35
49
  message = UserMailer.send(method)
36
- message.to # trigger creation
50
+ message.respond_to?(:deliver_now) ? message.deliver_now : message.deliver
37
51
  ahoy_message = Ahoy::Message.first
38
52
  assert_equal 1, Ahoy::Message.count
39
53
  assert_equal "test@example.org", ahoy_message.to
data/test/test_helper.rb CHANGED
@@ -4,5 +4,9 @@ require "minitest/autorun"
4
4
  require "minitest/pride"
5
5
  require "combustion"
6
6
 
7
+ Minitest::Test = Minitest::Unit::TestCase unless defined?(Minitest::Test)
8
+
7
9
  Combustion.path = "test/internal"
8
10
  Combustion.initialize! :all
11
+
12
+ ActionMailer::Base.delivery_method = :test
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ahoy_email
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Andrew Kane
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-12-17 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -161,6 +161,9 @@ files:
161
161
  - lib/ahoy_email/version.rb
162
162
  - lib/generators/ahoy_email/install_generator.rb
163
163
  - lib/generators/ahoy_email/templates/install.rb
164
+ - test/gemfiles/actionmailer32.gemfile
165
+ - test/gemfiles/actionmailer40.gemfile
166
+ - test/gemfiles/actionmailer41.gemfile
164
167
  - test/internal/config/database.yml
165
168
  - test/internal/config/routes.rb
166
169
  - test/internal/db/schema.rb
@@ -186,13 +189,17 @@ required_rubygems_version: !ruby/object:Gem::Requirement
186
189
  version: '0'
187
190
  requirements: []
188
191
  rubyforge_project:
189
- rubygems_version: 2.4.5.1
192
+ rubygems_version: 2.6.1
190
193
  signing_key:
191
194
  specification_version: 4
192
195
  summary: Simple, powerful email tracking for Rails
193
196
  test_files:
197
+ - test/gemfiles/actionmailer32.gemfile
198
+ - test/gemfiles/actionmailer40.gemfile
199
+ - test/gemfiles/actionmailer41.gemfile
194
200
  - test/internal/config/database.yml
195
201
  - test/internal/config/routes.rb
196
202
  - test/internal/db/schema.rb
197
203
  - test/mailer_test.rb
198
204
  - test/test_helper.rb
205
+ has_rdoc: