ahoy_email 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -4
- data/CHANGELOG.md +5 -0
- data/Gemfile +1 -1
- data/README.md +1 -1
- data/Rakefile +1 -0
- data/ahoy_email.gemspec +2 -0
- data/app/controllers/ahoy/messages_controller.rb +1 -1
- data/lib/ahoy_email.rb +2 -2
- data/lib/ahoy_email/mailer.rb +1 -1
- data/lib/ahoy_email/processor.rb +4 -3
- data/lib/ahoy_email/version.rb +1 -1
- data/lib/generators/ahoy_email/install_generator.rb +7 -1
- data/lib/generators/ahoy_email/templates/install.rb +1 -1
- data/test/gemfiles/{actionmailer32.gemfile → actionmailer50.gemfile} +1 -1
- data/test/mailer_test.rb +45 -14
- metadata +5 -9
- data/test/gemfiles/actionmailer40.gemfile +0 -6
- data/test/gemfiles/actionmailer41.gemfile +0 -6
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a367225c4c07c790df8fe4267f5bf7d230921b0e
|
4
|
+
data.tar.gz: 9360b86e5075df7bf02e427a689c035db77faaf7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e4c94a2e17739b8400c1cfccf870f3774c131f23c46ffc062e94140156565e9b002b83ebf3fbd440f857353038274bca4139365267756dfcb7b75bdde2d4eb66
|
7
|
+
data.tar.gz: da84e8725823073ae8aa5d7b636fac645786cff90484bd381b5ce8d894d0556764a9bbd2df9649265ff3d4b00ba310a3ad6dd1090fe88d86bccd7e82ea7231bd
|
data/.travis.yml
CHANGED
@@ -2,7 +2,7 @@ language: ruby
|
|
2
2
|
rvm:
|
3
3
|
- 2.3.0
|
4
4
|
sudo: false
|
5
|
-
script:
|
5
|
+
script: bundle exec rake test
|
6
6
|
before_script:
|
7
7
|
- gem install bundler
|
8
8
|
notifications:
|
@@ -11,7 +11,5 @@ notifications:
|
|
11
11
|
on_failure: change
|
12
12
|
gemfile:
|
13
13
|
- Gemfile
|
14
|
+
- test/gemfiles/actionmailer50.gemfile
|
14
15
|
- test/gemfiles/actionmailer42.gemfile
|
15
|
-
- test/gemfiles/actionmailer41.gemfile
|
16
|
-
- test/gemfiles/actionmailer40.gemfile
|
17
|
-
- test/gemfiles/actionmailer32.gemfile
|
data/CHANGELOG.md
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
data/Rakefile
CHANGED
data/ahoy_email.gemspec
CHANGED
@@ -18,6 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
+
spec.required_ruby_version = ">= 2.0.0"
|
22
|
+
|
21
23
|
spec.add_runtime_dependency "rails"
|
22
24
|
spec.add_runtime_dependency "addressable"
|
23
25
|
spec.add_runtime_dependency "nokogiri"
|
data/lib/ahoy_email.rb
CHANGED
@@ -11,7 +11,7 @@ require "ahoy_email/mailer"
|
|
11
11
|
require "ahoy_email/engine"
|
12
12
|
|
13
13
|
module AhoyEmail
|
14
|
-
mattr_accessor :secret_token, :options, :subscribers, :belongs_to
|
14
|
+
mattr_accessor :secret_token, :options, :subscribers, :belongs_to, :invalid_redirect_url
|
15
15
|
|
16
16
|
self.options = {
|
17
17
|
message: true,
|
@@ -41,7 +41,7 @@ module AhoyEmail
|
|
41
41
|
end
|
42
42
|
|
43
43
|
def self.message_model
|
44
|
-
@message_model || Ahoy::Message
|
44
|
+
(defined?(@message_model) && @message_model) || ::Ahoy::Message
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
data/lib/ahoy_email/mailer.rb
CHANGED
data/lib/ahoy_email/processor.rb
CHANGED
@@ -82,7 +82,7 @@ module AhoyEmail
|
|
82
82
|
id: ahoy_message.token,
|
83
83
|
format: "gif"
|
84
84
|
)
|
85
|
-
pixel = ActionController::Base.helpers.image_tag(url, size: "1x1", alt:
|
85
|
+
pixel = ActionController::Base.helpers.image_tag(url, size: "1x1", alt: "")
|
86
86
|
|
87
87
|
# try to add before body tag
|
88
88
|
if raw_source.match(regex)
|
@@ -103,9 +103,10 @@ module AhoyEmail
|
|
103
103
|
next unless trackable?(uri)
|
104
104
|
# utm params first
|
105
105
|
if options[:utm_params] && !skip_attribute?(link, "utm-params")
|
106
|
-
params = uri.query_values ||
|
106
|
+
params = uri.query_values(Array) || []
|
107
107
|
UTM_PARAMETERS.each do |key|
|
108
|
-
params
|
108
|
+
next if params.any? { |k, _v| k == key } || !options[key.to_sym]
|
109
|
+
params << [key, options[key.to_sym]]
|
109
110
|
end
|
110
111
|
uri.query_values = params
|
111
112
|
link["href"] = uri.to_s
|
data/lib/ahoy_email/version.rb
CHANGED
@@ -22,7 +22,13 @@ module AhoyEmail
|
|
22
22
|
end
|
23
23
|
|
24
24
|
def copy_migration
|
25
|
-
migration_template "install.rb", "db/migrate/create_ahoy_messages.rb"
|
25
|
+
migration_template "install.rb", "db/migrate/create_ahoy_messages.rb", migration_version: migration_version
|
26
|
+
end
|
27
|
+
|
28
|
+
def migration_version
|
29
|
+
if ActiveRecord::VERSION::MAJOR >= 5
|
30
|
+
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
31
|
+
end
|
26
32
|
end
|
27
33
|
end
|
28
34
|
end
|
data/test/mailer_test.rb
CHANGED
@@ -17,11 +17,26 @@ class UserMailer < ActionMailer::Base
|
|
17
17
|
mail to: "test@example.org", subject: "Hello", body: "World"
|
18
18
|
end
|
19
19
|
|
20
|
-
|
20
|
+
def welcome4
|
21
|
+
html_message('<a href="http://example.org">Hi<a>')
|
22
|
+
end
|
21
23
|
|
22
|
-
def
|
23
|
-
|
24
|
+
def welcome5
|
25
|
+
html_message('<a href="http://example.org?baz[]=1&baz[]=2">Hi<a>')
|
24
26
|
end
|
27
|
+
|
28
|
+
private
|
29
|
+
|
30
|
+
def prevent_delivery_to_guests
|
31
|
+
mail.perform_deliveries = false
|
32
|
+
end
|
33
|
+
|
34
|
+
def html_message(html)
|
35
|
+
track click: false
|
36
|
+
mail to: "test@example.org", subject: "Hello" do |format|
|
37
|
+
format.html { render plain: html }
|
38
|
+
end
|
39
|
+
end
|
25
40
|
end
|
26
41
|
|
27
42
|
class MailerTest < Minitest::Test
|
@@ -45,16 +60,32 @@ class MailerTest < Minitest::Test
|
|
45
60
|
assert_equal 0, Ahoy::Message.count
|
46
61
|
end
|
47
62
|
|
48
|
-
def
|
49
|
-
message = UserMailer.
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
63
|
+
def test_utm_params
|
64
|
+
message = UserMailer.welcome4
|
65
|
+
body = message.body.to_s
|
66
|
+
assert_match "utm_campaign=welcome4", body
|
67
|
+
assert_match "utm_medium=email", body
|
68
|
+
assert_match "utm_source=user_mailer", body
|
69
|
+
end
|
70
|
+
|
71
|
+
def test_array_params
|
72
|
+
message = UserMailer.welcome5
|
73
|
+
body = message.body.to_s
|
74
|
+
assert_match "baz%5B%5D=1&baz%5B%5D=2", body
|
59
75
|
end
|
76
|
+
|
77
|
+
private
|
78
|
+
|
79
|
+
def assert_message(method)
|
80
|
+
message = UserMailer.send(method)
|
81
|
+
message.respond_to?(:deliver_now) ? message.deliver_now : message.deliver
|
82
|
+
ahoy_message = Ahoy::Message.first
|
83
|
+
assert_equal 1, Ahoy::Message.count
|
84
|
+
assert_equal "test@example.org", ahoy_message.to
|
85
|
+
assert_equal "UserMailer##{method}", ahoy_message.mailer
|
86
|
+
assert_equal "Hello", ahoy_message.subject
|
87
|
+
assert_equal "user_mailer", ahoy_message.utm_source
|
88
|
+
assert_equal "email", ahoy_message.utm_medium
|
89
|
+
assert_equal method.to_s, ahoy_message.utm_campaign
|
90
|
+
end
|
60
91
|
end
|
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.
|
4
|
+
version: 0.5.0
|
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: 2017-05-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -162,10 +162,8 @@ files:
|
|
162
162
|
- lib/ahoy_email/version.rb
|
163
163
|
- lib/generators/ahoy_email/install_generator.rb
|
164
164
|
- lib/generators/ahoy_email/templates/install.rb
|
165
|
-
- test/gemfiles/actionmailer32.gemfile
|
166
|
-
- test/gemfiles/actionmailer40.gemfile
|
167
|
-
- test/gemfiles/actionmailer41.gemfile
|
168
165
|
- test/gemfiles/actionmailer42.gemfile
|
166
|
+
- test/gemfiles/actionmailer50.gemfile
|
169
167
|
- test/internal/config/database.yml
|
170
168
|
- test/internal/config/routes.rb
|
171
169
|
- test/internal/db/schema.rb
|
@@ -183,7 +181,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
183
181
|
requirements:
|
184
182
|
- - ">="
|
185
183
|
- !ruby/object:Gem::Version
|
186
|
-
version:
|
184
|
+
version: 2.0.0
|
187
185
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
188
186
|
requirements:
|
189
187
|
- - ">="
|
@@ -196,10 +194,8 @@ signing_key:
|
|
196
194
|
specification_version: 4
|
197
195
|
summary: Simple, powerful email tracking for Rails
|
198
196
|
test_files:
|
199
|
-
- test/gemfiles/actionmailer32.gemfile
|
200
|
-
- test/gemfiles/actionmailer40.gemfile
|
201
|
-
- test/gemfiles/actionmailer41.gemfile
|
202
197
|
- test/gemfiles/actionmailer42.gemfile
|
198
|
+
- test/gemfiles/actionmailer50.gemfile
|
203
199
|
- test/internal/config/database.yml
|
204
200
|
- test/internal/config/routes.rb
|
205
201
|
- test/internal/db/schema.rb
|