Sha256: 3375d6738786389ea2627b458a16dad6fbb0be6c92102548c6ede67eb7bc2dfa

Contents?: true

Size: 1.26 KB

Versions: 64

Compression:

Stored size: 1.26 KB

Contents

require 'spec_helper'

# # Attributes
describe Effective::StripeCharge do
  let(:order) { FactoryGirl.create(:order_with_subscription) }
  let(:charge) { Effective::StripeCharge.new(order) }

  before { StripeMock.start }
  after { StripeMock.stop }

  it 'can be initialized with an order' do
    charge = Effective::StripeCharge.new(order)
    charge.order.should eq order
    charge.effective_order_id.should eq order.to_param
  end

  it 'can be initialized without an order' do
    charge = Effective::StripeCharge.new(:token => 'tok_123', :effective_order_id => 3)
    charge.token.should eq 'tok_123'
    charge.effective_order_id.should eq 3
    charge.order.nil?.should eq true
  end

  it 'performs validations' do
    charge = Effective::StripeCharge.new()
    charge.valid?.should eq false
    charge.errors[:token].present?.should eq true
    charge.errors[:effective_order_id].present?.should eq true
  end

  it '#order_items returns all OrderItems where the purchasable is not a Subscription' do
    charge.order_items.all? { |oi| oi.purchasable_type != 'Effective::Subscription'}.should eq true
  end

  it '#subscriptions returns all Subscriptions (not order items)' do
    charge.subscriptions.all? { |oi| oi.kind_of?(Effective::Subscription) }.should eq true
  end

end

Version data entries

64 entries across 64 versions & 1 rubygems

Version Path
effective_orders-1.8.1 spec/models/stripe_charge_spec.rb
effective_orders-1.8.0 spec/models/stripe_charge_spec.rb
effective_orders-1.7.5 spec/models/stripe_charge_spec.rb
effective_orders-1.7.4 spec/models/stripe_charge_spec.rb
effective_orders-1.7.3 spec/models/stripe_charge_spec.rb
effective_orders-1.7.2 spec/models/stripe_charge_spec.rb
effective_orders-1.7.1 spec/models/stripe_charge_spec.rb
effective_orders-1.7.0 spec/models/stripe_charge_spec.rb
effective_orders-1.6.6 spec/models/stripe_charge_spec.rb
effective_orders-1.6.5 spec/models/stripe_charge_spec.rb
effective_orders-1.6.4 spec/models/stripe_charge_spec.rb
effective_orders-1.6.3 spec/models/stripe_charge_spec.rb
effective_orders-1.6.1 spec/models/stripe_charge_spec.rb
effective_orders-1.6.0 spec/models/stripe_charge_spec.rb
effective_orders-1.5.9 spec/models/stripe_charge_spec.rb
effective_orders-1.5.8 spec/models/stripe_charge_spec.rb
effective_orders-1.5.7 spec/models/stripe_charge_spec.rb
effective_orders-1.5.5 spec/models/stripe_charge_spec.rb
effective_orders-1.5.4 spec/models/stripe_charge_spec.rb
effective_orders-1.5.3 spec/models/stripe_charge_spec.rb