mailkick 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 -0
- data/CHANGELOG.md +6 -0
- data/app/helpers/mailkick/url_helper.rb +4 -3
- data/lib/mailkick.rb +4 -2
- data/lib/mailkick/engine.rb +1 -1
- data/lib/mailkick/version.rb +1 -1
- data/test/mailkick_test.rb +2 -2
- data/test/test_helper.rb +0 -2
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7a36d760e07c5d02d2a0a685c4ced2e9075eb0e272f7814b08fd477fd282a9a0
|
4
|
+
data.tar.gz: 6038e41c31a36c14fd7438fc870531773fb6098d0932e72b4d187dc9c51ef634
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f1f4229e0f2191437d1cda0ef791683908cbc9d5a98519ba8fd00f9250b6f64f9aa0f9ec0df8be05c62506bf6d7e407bf610643d7f2faf979c066d8e977f7efc
|
7
|
+
data.tar.gz: b2801fbe7e9bb5de9d3eda275e7b162b68ccf5ff3ad352cb5b4462a3e617edb44cae177652d3c7ecda70f7dd35abc2755cc958219e761510270f32605f7eae91
|
data/.gitignore
CHANGED
data/CHANGELOG.md
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
module Mailkick
|
2
2
|
module UrlHelper
|
3
|
-
def mailkick_unsubscribe_url(email: nil, list: nil, **options)
|
4
|
-
email ||= controller.message.to.first
|
3
|
+
def mailkick_unsubscribe_url(email: nil, user: nil, list: nil, **options)
|
4
|
+
email ||= controller.try(:message).try(:to).try(:first)
|
5
|
+
|
5
6
|
Mailkick::Engine.routes.url_helpers.url_for(
|
6
7
|
(ActionMailer::Base.default_url_options || {}).merge(options).merge(
|
7
8
|
controller: "mailkick/subscriptions",
|
8
9
|
action: "unsubscribe",
|
9
|
-
id: Mailkick.generate_token(email, list: list)
|
10
|
+
id: Mailkick.generate_token(email, user: user, list: list)
|
10
11
|
)
|
11
12
|
)
|
12
13
|
end
|
data/lib/mailkick.rb
CHANGED
@@ -91,8 +91,10 @@ module Mailkick
|
|
91
91
|
@message_verifier ||= ActiveSupport::MessageVerifier.new(Mailkick.secret_token)
|
92
92
|
end
|
93
93
|
|
94
|
-
def self.generate_token(email, list: nil)
|
95
|
-
|
94
|
+
def self.generate_token(email, user: nil, list: nil)
|
95
|
+
raise ArgumentError, "Missing email" unless email
|
96
|
+
|
97
|
+
user ||= Mailkick.user_method.call(email) if Mailkick.user_method
|
96
98
|
message_verifier.generate([email, user.try(:id), user.try(:class).try(:name), list])
|
97
99
|
end
|
98
100
|
end
|
data/lib/mailkick/engine.rb
CHANGED
data/lib/mailkick/version.rb
CHANGED
data/test/mailkick_test.rb
CHANGED
@@ -4,9 +4,9 @@ class MailkickTest < Minitest::Test
|
|
4
4
|
def test_unsubscribe_url
|
5
5
|
message = UserMailer.welcome.deliver_now
|
6
6
|
html_body = message.html_part.body.to_s
|
7
|
-
assert_includes html_body, "
|
7
|
+
assert_includes html_body, "unsubscribe"
|
8
8
|
text_body = message.text_part.body.to_s
|
9
|
-
assert_includes text_body, "
|
9
|
+
assert_includes text_body, "unsubscribe"
|
10
10
|
end
|
11
11
|
|
12
12
|
def test_opt_out
|
data/test/test_helper.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mailkick
|
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: 2018-04-
|
11
|
+
date: 2018-04-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|