Sha256: fb6b902d9c83eae3d4c4731ca40a550ce7396dd06abf6e036eaabfd9c2a060f3

Contents?: true

Size: 1.72 KB

Versions: 29

Compression:

Stored size: 1.72 KB

Contents

# frozen_string_literal: true

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

module Stripe
  class SubscriptionItemTest < Test::Unit::TestCase
    should "be listable" do
      items = Stripe::SubscriptionItem.list(
        subscription: "sub_123"
      )
      assert_requested :get, "#{Stripe.api_base}/v1/subscription_items",
                       query: { subscription: "sub_123" }
      assert items.data.is_a?(Array)
      assert items.data[0].is_a?(Stripe::SubscriptionItem)
    end

    should "be retrievable" do
      item = Stripe::SubscriptionItem.retrieve("si_123")
      assert_requested :get, "#{Stripe.api_base}/v1/subscription_items/si_123"
      assert item.is_a?(Stripe::SubscriptionItem)
    end

    should "be creatable" do
      item = Stripe::SubscriptionItem.create(
        plan: "sapphire-elite",
        quantity: 3,
        subscription: "sub_123"
      )
      assert_requested :post, "#{Stripe.api_base}/v1/subscription_items"
      assert item.is_a?(Stripe::SubscriptionItem)
    end

    should "be saveable" do
      item = Stripe::SubscriptionItem.retrieve("si_123")
      item.quantity = 4
      item.save
      assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/#{item.id}"
    end

    should "be updateable" do
      item = Stripe::SubscriptionItem.update("si_123", metadata: { foo: "bar" })
      assert_requested :post, "#{Stripe.api_base}/v1/subscription_items/si_123"
      assert item.is_a?(Stripe::SubscriptionItem)
    end

    should "be deletable" do
      item = Stripe::SubscriptionItem.retrieve("si_123")
      item = item.delete
      assert_requested :delete, "#{Stripe.api_base}/v1/subscription_items/#{item.id}"
      assert item.is_a?(Stripe::SubscriptionItem)
    end
  end
end

Version data entries

29 entries across 29 versions & 1 rubygems

Version Path
stripe-3.31.0 test/stripe/subscription_item_test.rb
stripe-3.30.0 test/stripe/subscription_item_test.rb
stripe-3.29.0 test/stripe/subscription_item_test.rb
stripe-3.28.0 test/stripe/subscription_item_test.rb
stripe-3.27.0 test/stripe/subscription_item_test.rb
stripe-3.26.1 test/stripe/subscription_item_test.rb
stripe-3.26.0 test/stripe/subscription_item_test.rb
stripe-3.25.0 test/stripe/subscription_item_test.rb
stripe-3.24.0 test/stripe/subscription_item_test.rb