Sha256: 688e7b811eb197436592f6a44abaf755383f487092aebc67a31a0dd2660d14ef

Contents?: true

Size: 929 Bytes

Versions: 2

Compression:

Stored size: 929 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
        @mock.expects(:post).once.
          with("#{Stripe.api_base}/v1/updateableresources/id", nil, 'foo=bar').
          returns(make_response({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

2 entries across 2 versions & 1 rubygems

Version Path
stripe-1.58.0 test/stripe/api_operations_test.rb
stripe-1.57.1 test/stripe/api_operations_test.rb