Sha256: 28141e1f60b9434c9275d3879e09e733d0bdee8dac00f4f5cc64adf31a93327d
Contents?: true
Size: 1.91 KB
Versions: 62
Compression:
Stored size: 1.91 KB
Contents
require 'test_helper' module Workarea module Pricing class Discount class FreeGiftTest < TestCase include DiscountConditionTests::OrderTotal include DiscountConditionTests::PromoCodes def qualified_discount @qualified_discount ||= FreeGift.new(category_ids: ['CATEGORY']) end alias_method :order_total_discount, :qualified_discount alias_method :promo_codes_discount, :qualified_discount def discounted_order @discounted_order ||= Workarea::Order.new.tap do |order| order.items.build(category_ids: ['CATEGORY']) end end def test_catalog_qualifies? order = Workarea::Order.new order.items.build( product_id: 'PRODUCT', category_ids: ['CATEGORY'] ) discount = FreeGift.new assert(discount.catalog_qualifies?(order)) discount = FreeGift.new(category_ids: ['CATEGORY1']) refute(discount.catalog_qualifies?(order)) discount = FreeGift.new(category_ids: ['CATEGORY']) assert(discount.catalog_qualifies?(order)) discount = FreeGift.new(product_ids: ['PRODUCT1']) refute(discount.catalog_qualifies?(order)) discount = FreeGift.new(product_ids: ['PRODUCT']) assert(discount.catalog_qualifies?(order)) discount = FreeGift.new( product_ids: ['PRODUCT1'], category_ids: ['CATEGORY1'] ) refute(discount.catalog_qualifies?(order)) discount = FreeGift.new( product_ids: ['PRODUCT'], category_ids: ['CATEGORY1'] ) assert(discount.catalog_qualifies?(order)) discount = FreeGift.new( product_ids: ['PRODUCT1'], category_ids: ['CATEGORY'] ) assert(discount.catalog_qualifies?(order)) end end end end end
Version data entries
62 entries across 62 versions & 1 rubygems