Sha256: 0e5cde64e928e60530fa50aa02a13d9dc8b834334963672a66213826bb170595

Contents?: true

Size: 1.85 KB

Versions: 16

Compression:

Stored size: 1.85 KB

Contents

require './test/test_helper'

class RedemptionTest < Minitest::Test

  def get_first_redemption
    VCR.use_cassette('redemption/search_by_member_key_first') do
      @first_redemption = Access::Redemption.search_by_member('API_RUBY_GEM_TEST').offer_redemptions.first
    end
  end

  def test_search_offer_redemptions_by_member
    VCR.use_cassette('redemption/search_by_member_key') do
      redemption_response = Access::Redemption.search_by_member('API_RUBY_GEM_TEST')
      assert redemption_response.success
      assert_kind_of Access::RedemptionResponse, redemption_response
      assert_kind_of Access::Offer, redemption_response.offer_redemptions.first.offer
      assert_kind_of Access::Member, redemption_response.offer_redemptions.first.member
    end
  end

  def test_find_offer_redemptions_by_member
    get_first_redemption
    VCR.use_cassette('redemption/find_by_member_key') do
      redemption_response = Access::Redemption.find_by_member('API_RUBY_GEM_TEST', @first_redemption.usage_redeem_key)
      assert redemption_response.success
      assert_kind_of Access::RedemptionResponse, redemption_response
      assert_kind_of Access::Offer, redemption_response.offer_redemptions.first.offer
      assert_kind_of Access::Member, redemption_response.offer_redemptions.first.member
    end
  end

  def test_search_offer_redemptions_by_member_with_no_redemptions
    VCR.use_cassette('redemption/search_by_member_key_without_redemptions') do
      redemption_response = Access::Redemption.search_by_member('API_RUBY_GEM_TEST_NOREDEMPTIONS')
      refute redemption_response.success
      assert_kind_of Access::RedemptionResponse, redemption_response
      assert_kind_of Access::Error, redemption_response.error
      assert_equal 200, redemption_response.error.status_code
      assert_equal "No redemptions found.", redemption_response.error.message
    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
access-2.3.0.pre.rc2 test/access/redemption_test.rb
access-2.3.0.pre.rc1 test/access/redemption_test.rb
access-2.2.0 test/access/redemption_test.rb
access-2.1.5 test/access/redemption_test.rb
access-2.1.4 test/access/redemption_test.rb
access-2.1.3 test/access/redemption_test.rb
access-2.1.2 test/access/redemption_test.rb
access-2.1.1 test/access/redemption_test.rb
access-2.1.0 test/access/redemption_test.rb
access-2.0.55 test/access/redemption_test.rb
access-2.0.54 test/access/redemption_test.rb
access-2.0.53 test/access/redemption_test.rb
access-2.0.52 test/access/redemption_test.rb
access-2.0.51 test/access/redemption_test.rb
access-2.0.50 test/access/redemption_test.rb
access-2.0.49 test/access/redemption_test.rb