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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 7342fb3956753b14f1345a70153ac76cc6cc73290a7b4c1d9e3f9a1b29e6a216
4
- data.tar.gz: 06a13e7037c2ab1ffcab78f93f7a99272aa00b59f3388878ad10498d7ed73e70
3
+ metadata.gz: 7a36d760e07c5d02d2a0a685c4ced2e9075eb0e272f7814b08fd477fd282a9a0
4
+ data.tar.gz: 6038e41c31a36c14fd7438fc870531773fb6098d0932e72b4d187dc9c51ef634
5
5
  SHA512:
6
- metadata.gz: 2d0a3d927fee65871caf6b37d79e83663e45c382396e941e03651ec36de13e19680107f9582e4e9010f65454361d32e16b77787d8e0657857029ff05b3e2e510
7
- data.tar.gz: 72698be727b60185179d2004af23531cf3812fabf6e68a8ad0d4da4b0119804bc3591dd60aa1f7a5c92b1d3d0c896f5329572a6e331985724f00c8778abb6623
6
+ metadata.gz: f1f4229e0f2191437d1cda0ef791683908cbc9d5a98519ba8fd00f9250b6f64f9aa0f9ec0df8be05c62506bf6d7e407bf610643d7f2faf979c066d8e977f7efc
7
+ data.tar.gz: b2801fbe7e9bb5de9d3eda275e7b162b68ccf5ff3ad352cb5b4462a3e617edb44cae177652d3c7ecda70f7dd35abc2755cc958219e761510270f32605f7eae91
data/.gitignore CHANGED
@@ -22,3 +22,4 @@ tmp
22
22
  mkmf.log
23
23
  *.log
24
24
  *.sqlite
25
+ *.lock
data/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 0.3.1
2
+
3
+ - Fixed `Secret should not be nil` error in Rails 5.2
4
+ - Gracefully handle missing email
5
+ - Added `user` option to `mailkick_unsubscribe_url`
6
+
1
7
  ## 0.3.0
2
8
 
3
9
  - Improved performance
@@ -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
- user = Mailkick.user_method.call(email) if Mailkick.user_method
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
@@ -7,7 +7,7 @@ module Mailkick
7
7
 
8
8
  Mailkick.secret_token ||= begin
9
9
  creds =
10
- if app.respond_to?(:credentials)
10
+ if app.respond_to?(:credentials) && app.credentials.secret_key_base
11
11
  app.credentials
12
12
  elsif app.respond_to?(:secrets)
13
13
  app.secrets
@@ -1,3 +1,3 @@
1
1
  module Mailkick
2
- VERSION = "0.3.0"
2
+ VERSION = "0.3.1"
3
3
  end
@@ -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, "BAhbCUkiFXRlc3RAZXhhbXBsZS5vcmcGOgZFVDAwMA==--f435e91ba90e1732d3e999af1f2126dcc8182a5d"
7
+ assert_includes html_body, "unsubscribe"
8
8
  text_body = message.text_part.body.to_s
9
- assert_includes text_body, "BAhbCUkiFXRlc3RAZXhhbXBsZS5vcmcGOgZFVDAwMA==--f435e91ba90e1732d3e999af1f2126dcc8182a5d"
9
+ assert_includes text_body, "unsubscribe"
10
10
  end
11
11
 
12
12
  def test_opt_out
data/test/test_helper.rb CHANGED
@@ -16,5 +16,3 @@ end
16
16
 
17
17
  ActiveRecord::Base.logger = ActiveSupport::Logger.new(STDOUT) if ENV["VERBOSE"]
18
18
  ActionMailer::Base.delivery_method = :test
19
-
20
- Mailkick.secret_token = "test123"
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.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: 2018-04-20 00:00:00.000000000 Z
11
+ date: 2018-04-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport