lib/mailstro/test_strategy.rb in mailstro-0.0.8 vs lib/mailstro/test_strategy.rb in mailstro-0.0.9
- old
+ new
@@ -2,71 +2,33 @@
module TestStrategy
def self.enable
Mailstro.strategy = Mailstro::TestStrategy
end
- @@deliveries = []
- @@subscribes = []
- @@unsubscribes = []
+ @@deliveries = []
def self.clear
- @@deliveries = []
- @@subscribes = []
- @@unsubscribes = []
+ @@deliveries = []
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?(conditions)
@@deliveries.any? do |delivery|
result = true
if conditions.is_a?(Hash)
if conditions[:template_name]
result = result && delivery.template_name == conditions[:template_name]
end
if conditions[:to]
result = result && delivery.contact_email == conditions[:to]
end
- if conditions[:to_list_type]
- result = result && delivery.list_type == conditions[:to_list_type]
- end
- if conditions[:to_list_name]
- result = result && delivery.list_name == conditions[:to_list_name]
- end
else
result = delivery.template_name == conditions
end
result
- end
- 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