Module: Mailstro::TestStrategy
- Defined in:
- lib/mailstro/test_strategy.rb
Constant Summary collapse
- @@deliveries =
[]
- @@subscribes =
[]
- @@unsubscribes =
[]
Class Method Summary collapse
- .clear ⇒ Object
- .deliver(options) ⇒ Object
- .enable ⇒ Object
- .has_delivered?(conditions) ⇒ Boolean
- .has_subscribed?(contact_email, list_type, list_name) ⇒ Boolean
- .has_unsubscribed?(contact_email, list_type, list_name) ⇒ Boolean
- .list_deliver(options) ⇒ Object
- .subscribe(contact_email, list_type, list_name) ⇒ Object
- .unsubscribe(contact_email, list_type, list_name) ⇒ Object
Class Method Details
.clear ⇒ Object
11 12 13 14 15 |
# File 'lib/mailstro/test_strategy.rb', line 11 def self.clear @@deliveries = [] @@subscribes = [] @@unsubscribes = [] end |
.deliver(options) ⇒ Object
17 18 19 |
# File 'lib/mailstro/test_strategy.rb', line 17 def self.deliver() @@deliveries << Delivery.new() end |
.enable ⇒ Object
3 4 5 |
# File 'lib/mailstro/test_strategy.rb', line 3 def self.enable Mailstro.strategy = Mailstro::TestStrategy end |
.has_delivered?(conditions) ⇒ Boolean
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 |
# File 'lib/mailstro/test_strategy.rb', line 33 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 |
.has_subscribed?(contact_email, list_type, list_name) ⇒ Boolean
56 57 58 59 60 61 62 |
# File 'lib/mailstro/test_strategy.rb', line 56 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 |
.has_unsubscribed?(contact_email, list_type, list_name) ⇒ Boolean
64 65 66 67 68 69 70 |
# File 'lib/mailstro/test_strategy.rb', line 64 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 |
.list_deliver(options) ⇒ Object
21 22 23 |
# File 'lib/mailstro/test_strategy.rb', line 21 def self.list_deliver() @@deliveries << ListDelivery.new() end |
.subscribe(contact_email, list_type, list_name) ⇒ Object
25 26 27 |
# File 'lib/mailstro/test_strategy.rb', line 25 def self.subscribe(contact_email, list_type, list_name) @@subscribes << ListSubscribe.new(contact_email, list_type, list_name) end |
.unsubscribe(contact_email, list_type, list_name) ⇒ Object
29 30 31 |
# File 'lib/mailstro/test_strategy.rb', line 29 def self.unsubscribe(contact_email, list_type, list_name) @@unsubscribes << ListUnsubscribe.new(contact_email, list_type, list_name) end |