module Mailstro module TestStrategy def self.enable Mailstro.strategy = Mailstro::TestStrategy end @@deliveries = [] @@subscribes = [] @@unsubscribes = [] def self.deliveries @@deliveries end def self.clear @@deliveries = [] @@subscribes = [] @@unsubscribes = [] end def self.deliver(options) @@deliveries << Delivery.new(options) end def self.list_deliver(options) @@deliveries << ListDelivery.new(options) end def self.subscribe(contact_email, list_type, list_name) @@subscribes << ListSubscribe.new(contact_email, list_type, list_name) end def self.unsubscribe(contact_email, list_type, list_name) @@unsubscribes << ListUnsubscribe.new(contact_email, list_type, list_name) end def self.has_delivered?(template_name) @@deliveries.map(&:template_name).include?(template_name) end def self.has_subscribed?(contact_email, list_type, list_name) @@subscribes.any? do |subscribe| subscribe.contact_email == contact_email && subscribe.list_type == list_type && subscribe.list_name == list_name end end def self.has_unsubscribed?(contact_email, list_type, list_name) @@unsubscribes.any? do |unsubscribe| unsubscribe.contact_email == contact_email && unsubscribe.list_type == list_type && unsubscribe.list_name == list_name end end end end