Sha256: 7fc3ad10a2d1aa5a63ca0d4e7e9011350498ead7471d6cdf172c958ed0fad3b5
Contents?: true
Size: 1.45 KB
Versions: 15
Compression:
Stored size: 1.45 KB
Contents
require 'test_helper' class CouponTest < ActiveSupport::TestCase should_validate_presence_of :code context "instance" do setup do @checkout = Factory(:checkout) @coupon = Factory(:coupon) end context "expires_at < now" do setup { @coupon.expires_at = Time.now - 1.day } should "not be eligible" do assert !@coupon.eligible?(Factory(:order)) end end context "expires_at > now" do setup { @coupon.expires_at = Time.now + 1.day } should "be eligible" do assert @coupon.eligible?(Factory(:order)) end end context "with usage limit of 1" do setup { @coupon.usage_limit = 1 } context "when coupon has already been used" do setup { @coupon.create_discount(Factory(:order)) } should "not be eligible" do assert !@coupon.eligible?(Factory(:order)) end end context "when coupon has not yet been used" do should "be eligible" do assert @coupon.eligible?(Factory(:order)) end end end context "with starts_at > now" do setup { @coupon.starts_at = Time.now + 1.day } should "not be eligible" do assert !@coupon.eligible?(Factory(:order)) end end context "with starts_at < now" do setup { @coupon.starts_at = Time.now - 1.day } should "be eligible" do assert @coupon.eligible?(Factory(:order)) end end end end
Version data entries
15 entries across 15 versions & 2 rubygems