Sha256: 9756c897f8f25c263453848bc9be896d558165e44b10c2fd2c5e157eea812260

Contents?: true

Size: 1.72 KB

Versions: 9

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

9 entries across 9 versions & 1 rubygems

Version Path
stripe-3.23.0 test/stripe/subscription_item_test.rb
stripe-3.22.0 test/stripe/subscription_item_test.rb
stripe-3.21.0 test/stripe/subscription_item_test.rb
stripe-3.20.0 test/stripe/subscription_item_test.rb
stripe-3.19.0 test/stripe/subscription_item_test.rb
stripe-3.18.0 test/stripe/subscription_item_test.rb
stripe-3.17.2 test/stripe/subscription_item_test.rb
stripe-3.17.1 test/stripe/subscription_item_test.rb
stripe-3.17.0 test/stripe/subscription_item_test.rb