lib/mailstro/test_strategy.rb in mailstro-0.0.7 vs lib/mailstro/test_strategy.rb in mailstro-0.0.8
- old
+ new
@@ -6,14 +6,10 @@
@@deliveries = []
@@subscribes = []
@@unsubscribes = []
- def self.deliveries
- @@deliveries
- end
-
def self.clear
@@deliveries = []
@@subscribes = []
@@unsubscribes = []
end
@@ -32,11 +28,30 @@
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)
+ 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 &&