1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-11-29 10:24:20 +01:00

fix statistics generation with cash coupon

This commit is contained in:
Sylvain 2016-11-29 14:57:21 +01:00
parent 1ebab285f3
commit 6c933857f4
2 changed files with 5 additions and 5 deletions

View File

@ -1,28 +1,28 @@
require 'test_helper'
class CouponApplyServiceTest < ActiveSupport::TestCase
class CouponServiceTest < ActiveSupport::TestCase
setup do
@jdupond = User.find_by(username: 'jdupond')
@cash_coupon = Coupon.find_by(code: 'ZERG6H1R65H')
end
test 'user apply percent coupon to cart' do
total = CouponApplyService.new.(1000, 'SUNNYFABLAB', @jdupond.id)
total = CouponService.new.(1000, 'SUNNYFABLAB', @jdupond.id)
assert_equal 850, total
end
test 'user cannot apply excessive coupon to cart' do
total = CouponApplyService.new.(1000, @cash_coupon, @jdupond.id)
total = CouponService.new.(1000, @cash_coupon, @jdupond.id)
assert_equal 1000, total
end
test 'user cannot apply invalid coupon to cart' do
total = CouponApplyService.new.(1000, 'INVALIDCODE', @jdupond.id)
total = CouponService.new.(1000, 'INVALIDCODE', @jdupond.id)
assert_equal 1000, total
end
test 'user cannot apply expired coupon to cart' do
total = CouponApplyService.new.(1000, 'XMAS10', @jdupond.id)
total = CouponService.new.(1000, 'XMAS10', @jdupond.id)
assert_equal 1000, total
end
end