Created
December 8, 2015 10:52
-
-
Save Gaurav2728/4a99a963408168178326 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require 'test_helper' | |
| class RedemptionCodeTest < ActiveSupport::TestCase | |
| def setup | |
| @business = businesses :vinovolo | |
| @business.enabled_reward_back = true | |
| @user = users :warren | |
| @user.punchh_app = punchh_apps :vinovolo | |
| end | |
| def test_process! | |
| final_points = 100 | |
| business = create( | |
| :business, | |
| high_redemption_threshold: 1 | |
| ) | |
| redemption = create( | |
| :redemption, | |
| business: business, | |
| admin_id: "1", | |
| force_message: "this is a force message", | |
| requested_punches: 10 | |
| ) | |
| redemption_code = create( | |
| :redemption_code, | |
| business: business, | |
| redemption: redemption | |
| ) | |
| HighRedeemNotificationWorker.stubs(:perform_in) | |
| redemption_code.process!(final_points) | |
| assert_received(HighRedeemNotificationWorker, :perform_in) do |expect| | |
| expect.with(5, redemption.id) | |
| end | |
| end | |
| def test_code_expire_when_flag_is_off | |
| @business.enabled_reward_back = false | |
| redemption = @user.redemptions.find_by_business_id(@business) | |
| RedemptionCodesExpiryWorker.perform_in(0, redemption.redemption_code_id) | |
| code = redemption.redemption_code | |
| assert_equal code.business, @business | |
| assert_equal code.status, 'expired' | |
| end | |
| def test_code_expire_when_flag_is_on | |
| redemption = @user.redemptions.find_by_business_id(@business) | |
| RedemptionCodesExpiryWorker.stubs(:perform_in) | |
| assert_received(RedemptionCodesExpiryWorker, :perform_in) do |expect| | |
| expect.with(2, redemption.redemption_code_id) | |
| end | |
| code = redemption.redemption_code | |
| reward = redemption.rewards.find_by_redemption_id(redemption) | |
| assert_equal code.business, @business | |
| assert_equal code.status, 'expired' | |
| assert_equal reward.redemption_id, nil | |
| end | |
| # def test_code_expire_but_reward_not_alive | |
| # end | |
| # def test_code_expire_but_reward_not_alive | |
| # end | |
| # def test_code_expire_but_reward_not_found_with_redemption | |
| # end | |
| # def test_code_expire_reward_found_and_reward_alive | |
| # end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment