test/mailkick_test.rb in mailkick-0.2.1 vs test/mailkick_test.rb in mailkick-0.3.0
- old
+ new
@@ -2,10 +2,28 @@
class MailkickTest < Minitest::Test
def test_unsubscribe_url
message = UserMailer.welcome.deliver_now
html_body = message.html_part.body.to_s
- assert_equal "<p>BAhbCUkiFXRlc3RAZXhhbXBsZS5vcmcGOgZFVDAwMA%3D%3D--f435e91ba90e1732d3e999af1f2126dcc8182a5d</p>", html_body
+ assert_includes html_body, "BAhbCUkiFXRlc3RAZXhhbXBsZS5vcmcGOgZFVDAwMA==--f435e91ba90e1732d3e999af1f2126dcc8182a5d"
text_body = message.text_part.body.to_s
- assert_equal "Boom: BAhbCUkiFXRlc3RAZXhhbXBsZS5vcmcGOgZFVDAwMA%3D%3D--f435e91ba90e1732d3e999af1f2126dcc8182a5d", text_body
+ assert_includes text_body, "BAhbCUkiFXRlc3RAZXhhbXBsZS5vcmcGOgZFVDAwMA==--f435e91ba90e1732d3e999af1f2126dcc8182a5d"
+ end
+
+ def test_opt_out
+ email = "test2@example.org"
+ user = User.create!(email: email)
+
+ Mailkick.opt_out(email: email, user: user)
+
+ opt_outs = Mailkick::OptOut.all.to_a
+ assert_equal 1, opt_outs.size
+
+ opt_out = opt_outs.first
+ assert_equal email, opt_out.email
+ assert_equal user, opt_out.user
+
+ assert user.opted_out?
+ assert_equal 1, User.opted_out.count
+ assert_equal 0, User.not_opted_out.count
end
end