Sha256: 1d282269937b47c82fa07eba0ad8747c374206eb0b5a72e22685910d0e357be1

Contents?: true

Size: 1.81 KB

Versions: 12

Compression:

Stored size: 1.81 KB

Contents

require File.expand_path('../../../test_helper', __FILE__)

module Maestrano
  module Account
    class RecurringBillTest < Test::Unit::TestCase
      include APITestHelper

      should "be listable" do
        @api_mock.expects(:get).once.returns(test_response(test_account_recurring_bill_array))
        c = Maestrano::Account::RecurringBill.all
        assert c.data.kind_of? Array
        c.each do |bill|
          assert bill.kind_of?(Maestrano::Account::RecurringBill)
        end
      end

      should "be cancellable" do
        @api_mock.expects(:delete).once.returns(test_response(test_account_recurring_bill))
        c = Maestrano::Account::RecurringBill.construct_from(test_account_recurring_bill[:data])
        c.cancel
      end

      should "not be updateable" do
        assert_raises NoMethodError do
          @api_mock.stubs(:put).returns(test_response(test_account_recurring_bill))
          c = Maestrano::Account::RecurringBill.construct_from(test_account_recurring_bill[:data])
          c.save
        end
      end


      should "successfully create a remote bill when passed correct parameters" do
        @api_mock.expects(:post).with do |url, api_token, params|
          url == "#{Maestrano.param('api.host')}#{Maestrano.param('api.base')}account/recurring_bills" && api_token.nil? &&
          CGI.parse(params) == {"group_id"=>["cld-1"], "price_cents"=>["23000"], "currency"=>["AUD"], "description"=>["Some recurring bill"], "period"=>["Month"]}
        end.once.returns(test_response(test_account_recurring_bill))

        recurring_bill = Maestrano::Account::RecurringBill.create({
          group_id: 'cld-1',
          price_cents: 23000,
          currency: 'AUD',
          description: 'Some recurring bill',
          period: 'Month'
        })
        assert recurring_bill.id
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
maestrano-1.0.6 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.5 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.4 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.3 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.2 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.1 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.0 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.0.pre.RC9 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.0.pre.RC8 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.0.pre.RC7 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.0.pre.RC6 test/maestrano/account/recurring_bill_test.rb
maestrano-1.0.0.pre.RC5 test/maestrano/account/recurring_bill_test.rb