Sha256: 0c2458295017a07ce1a3607640ab3c2ad6b5a6086becac9b0d0bc72d07d2ead2

Contents?: true

Size: 939 Bytes

Versions: 25

Compression:

Stored size: 939 Bytes

Contents

# -*- coding: utf-8 -*-
require File.expand_path('../../test_helper', __FILE__)

module Stripe
  class ApiOperationsTest < Test::Unit::TestCase
    class UpdateableResource < APIResource
      include Stripe::APIOperations::Save

      def self.protected_fields
        [:protected]
      end
    end

    context ".update" do
      should "post the correct parameters to the resource URL" do
        stub_request(:post, "#{Stripe.api_base}/v1/updateableresources/id").
          with(body: { foo: "bar" }).
          to_return(body: JSON.generate({ foo: "bar" }))
        resource = UpdateableResource::update("id", { foo: "bar" })
        assert_equal('bar', resource.foo)
      end

      should "error on protected fields" do
        e = assert_raises do
          UpdateableResource::update("id", { protected: "bar" })
        end
        assert_equal "Cannot update protected field: protected", e.message
      end
    end
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
stripe-3.3.2 test/stripe/api_operations_test.rb
stripe-3.3.1 test/stripe/api_operations_test.rb
stripe-3.3.0 test/stripe/api_operations_test.rb
stripe-3.2.0 test/stripe/api_operations_test.rb
stripe-3.1.0 test/stripe/api_operations_test.rb
stripe-3.0.3 test/stripe/api_operations_test.rb
stripe-3.0.1 test/stripe/api_operations_test.rb
stripe-3.0.0 test/stripe/api_operations_test.rb
stripe-2.12.0 test/stripe/api_operations_test.rb
stripe-2.11.0 test/stripe/api_operations_test.rb
stripe-2.10.0 test/stripe/api_operations_test.rb
stripe-2.9.0 test/stripe/api_operations_test.rb
stripe-2.8.0 test/stripe/api_operations_test.rb
stripe-2.7.0 test/stripe/api_operations_test.rb
stripe-2.6.0 test/stripe/api_operations_test.rb
stripe-2.5.0 test/stripe/api_operations_test.rb
stripe-2.4.0 test/stripe/api_operations_test.rb
stripe-2.3.0 test/stripe/api_operations_test.rb
stripe-2.2.1 test/stripe/api_operations_test.rb
stripe-2.2.0 test/stripe/api_operations_test.rb