1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2024-12-01 12:24:28 +01:00
fab-manager/test/models/coupon_test.rb

19 lines
576 B
Ruby
Raw Normal View History

2016-08-03 17:25:00 +02:00
require 'test_helper'
class CouponTest < ActiveSupport::TestCase
test 'coupon must have a valid percentage' do
2016-08-08 15:43:02 +02:00
c = Coupon.new({name: 'Amazing deal', code: 'DISCOUNT', percent_off: 200, validity_per_user: 'once'})
assert c.invalid?
end
test 'expired coupon must return the proper status' do
c = Coupon.find_by_code('XMAS10')
assert c.status == 'expired'
end
test 'two coupons cannot have the same code' do
c = Coupon.new({name: 'Summer deals', code: 'SUNNYFABLAB', percent_off: 15, validity_per_user: 'always'})
2016-08-03 17:25:00 +02:00
assert c.invalid?
end
end