Module: Workarea::DiscountConditionTests::OrderTotal

Defined in:
lib/workarea/core/discount_condition_tests.rb

Instance Method Summary collapse

Instance Method Details

#test_order_total?Boolean

Returns:

  • (Boolean)


4
5
6
7
8
9
10
11
12
# File 'lib/workarea/core/discount_condition_tests.rb', line 4

def test_order_total?
  refute(order_total_discount.order_total?)

  order_total_discount.order_total = 0
  refute(order_total_discount.order_total?)

  order_total_discount.order_total = 1.to_m
  assert(order_total_discount.order_total?)
end

#test_order_total_qualifies?Boolean

Returns:

  • (Boolean)


14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/workarea/core/discount_condition_tests.rb', line 14

def test_order_total_qualifies?
  discounted_order.subtotal_price = 5.to_m

  assert(order_total_discount.order_total_qualifies?(discounted_order))

  order_total_discount.order_total_operator = :less_than

  order_total_discount.order_total = 4
  refute(order_total_discount.order_total_qualifies?(discounted_order))

  order_total_discount.order_total = 5
  refute(order_total_discount.order_total_qualifies?(discounted_order))

  order_total_discount.order_total = 6
  assert(order_total_discount.order_total_qualifies?(discounted_order))

  order_total_discount.order_total_operator = :greater_than

  order_total_discount.order_total = 4
  assert(order_total_discount.order_total_qualifies?(discounted_order))

  order_total_discount.order_total = 5
  refute(order_total_discount.order_total_qualifies?(discounted_order))

  order_total_discount.order_total = 6
  refute(order_total_discount.order_total_qualifies?(discounted_order))
end