Sha256: b1848f1c75a9c7d18df14c226501ce86301aaffc64cb86cb1237af93dce7c47d

Contents?: true

Size: 1.23 KB

Versions: 6

Compression:

Stored size: 1.23 KB

Contents

require File.expand_path(File.join(File.dirname(__FILE__), '../unit_test_helper'))

describe BraintreeRails::Discounts do
  before do
    stub_braintree_request(:get, '/plans', :body => fixture('plans.xml'))
  end

  describe '#initialize' do
    it 'should wrap an array of Braintree::Discount' do
      braintree_plan = Braintree::Plan.all.find { |p| p.id == 'plan_id' }
      braintree_discounts = braintree_plan.discounts
      discounts = BraintreeRails::Discounts.new(BraintreeRails::Plan.find('plan_id'))

      discounts.size.must_equal braintree_discounts.size

      braintree_discounts.each do |braintree_discount|
        discount = discounts.find(braintree_discount.id)
        BraintreeRails::Discount.attributes.each do |attribute|
          discount.send(attribute).must_equal braintree_discount.send(attribute)
        end
      end
    end
  end

  describe '#create' do
    it 'should throw NotSupportedApiException' do
      braintree_plan = Braintree::Plan.all.find { |p| p.id == 'plan_id' }
      braintree_discounts = braintree_plan.discounts
      discounts = BraintreeRails::Discounts.new(BraintreeRails::Plan.find('plan_id'))
      lambda { discounts.create }.must_raise BraintreeRails::NotSupportedApiException
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
braintree-rails-1.2.3 test/unit/braintree_rails/discounts_test.rb
braintree-rails-1.2.2 test/unit/braintree_rails/discounts_test.rb
braintree-rails-1.2.1 test/unit/braintree_rails/discounts_test.rb
braintree-rails-1.2.0 test/unit/braintree_rails/discounts_test.rb
braintree-rails-1.1.0 test/unit/braintree_rails/discounts_test.rb
braintree-rails-1.0.0 test/unit/braintree_rails/discounts_test.rb