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 +4 -4
- data/.gitignore +1 -1
- data/CHANGELOG.md +5 -0
- data/app/controllers/ahoy/messages_controller.rb +1 -1
- data/config/routes.rb +3 -1
- data/lib/ahoy_email/mailer.rb +12 -10
- data/lib/ahoy_email/processor.rb +1 -1
- data/lib/ahoy_email/version.rb +1 -1
- data/test/gemfiles/actionmailer32.gemfile +6 -0
- data/test/gemfiles/actionmailer40.gemfile +6 -0
- data/test/gemfiles/actionmailer41.gemfile +6 -0
- data/test/mailer_test.rb +16 -2
- data/test/test_helper.rb +4 -0
- metadata +10 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98b36aef95156ff7e1938250d562849b11099b18
|
4
|
+
data.tar.gz: 9b268aac653efb5427ccf133dabbd37418d3815a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 126c5fd727f97a61f9a84e99ba8a4fa12b587dc76ba4d21ad1d998ff57bc3f93f963292053b5fad70b4c4a0b90be0017c6978a7a63de3ef7c8ce15504221211b
|
7
|
+
data.tar.gz: 979d1310f3b909296202075e000ec7ca3f3ca8e409934534919ced80bc14dc9b5673219acd862c53fedaeba82c0dd2789d29f8a929e951c8f5ec94db16c63e14
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -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
data/lib/ahoy_email/mailer.rb
CHANGED
@@ -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
|
-
|
20
|
-
|
21
|
-
|
19
|
+
module InstanceMethods
|
20
|
+
def track(options = {})
|
21
|
+
self.ahoy_options = (ahoy_options || {}).merge(message: true).merge(options)
|
22
|
+
end
|
22
23
|
|
23
|
-
|
24
|
-
|
25
|
-
|
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
|
-
|
28
|
-
|
29
|
-
|
28
|
+
message = super
|
29
|
+
AhoyEmail::Processor.new(message, self).process
|
30
|
+
message
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
data/lib/ahoy_email/processor.rb
CHANGED
@@ -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
|
data/lib/ahoy_email/version.rb
CHANGED
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
|
-
|
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.
|
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.
|
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:
|
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.
|
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:
|