Sha256: ef68a0315306b312a5eaa395dc8d9fb27384593f2fad853762a9a8153d386cba

Contents?: true

Size: 1.37 KB

Versions: 11

Compression:

Stored size: 1.37 KB

Contents

# frozen_string_literal: true

require ::File.expand_path("../test_helper", __dir__)

module Stripe
  class PromotionCodeTest < Test::Unit::TestCase
    should "be listable" do
      promotion_codes = Stripe::PromotionCode.list
      assert_requested :get, "#{Stripe.api_base}/v1/promotion_codes"
      assert promotion_codes.data.is_a?(Array)
      assert promotion_codes.first.is_a?(Stripe::PromotionCode)
    end

    should "be retrievable" do
      coupon = Stripe::PromotionCode.retrieve("PROMO_123")
      assert_requested :get, "#{Stripe.api_base}/v1/promotion_codes/PROMO_123"
      assert coupon.is_a?(Stripe::PromotionCode)
    end

    should "be creatable" do
      coupon = Stripe::PromotionCode.create(
        coupon: "co_123",
        code: "MYCODE"
      )
      assert_requested :post, "#{Stripe.api_base}/v1/promotion_codes"
      assert coupon.is_a?(Stripe::PromotionCode)
    end

    should "be saveable" do
      coupon = Stripe::PromotionCode.retrieve("PROMO_123")
      coupon.metadata["key"] = "value"
      coupon.save
      assert_requested :post, "#{Stripe.api_base}/v1/promotion_codes/#{coupon.id}"
    end

    should "be updateable" do
      coupon = Stripe::PromotionCode.update("PROMO_123", metadata: { key: "value" })
      assert_requested :post, "#{Stripe.api_base}/v1/promotion_codes/PROMO_123"
      assert coupon.is_a?(Stripe::PromotionCode)
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
stripe-5.31.0 test/stripe/promotion_code_test.rb
stripe-5.30.0 test/stripe/promotion_code_test.rb
stripe-5.29.1 test/stripe/promotion_code_test.rb
stripe-5.29.0 test/stripe/promotion_code_test.rb
stripe-5.28.0 test/stripe/promotion_code_test.rb
stripe-5.27.0 test/stripe/promotion_code_test.rb
stripe-5.26.0 test/stripe/promotion_code_test.rb
stripe-5.25.0 test/stripe/promotion_code_test.rb
stripe-5.24.0 test/stripe/promotion_code_test.rb
stripe-5.23.1 test/stripe/promotion_code_test.rb
stripe-5.23.0 test/stripe/promotion_code_test.rb