Sha256: 32611fc88d1ecd44230c0ca8750c36916b6ca02a5e6460863b35fea1f79575b9

Contents?: true

Size: 946 Bytes

Versions: 2

Compression:

Stored size: 946 Bytes

Contents

require 'spec_helper'

describe Chargify::Migration::Preview, :fake_resource do
  context "#create" do
    it 'migrates the subscription' do
      id = generate(:subscription_id)
      subscription = build(:subscription, :id => id)
      subscription.stub!(:persisted?).and_return(true)
      expected_response = {:migration => {:prorated_adjustment_in_cents => -12500, :charge_in_cents => 90000, :payment_due_in_cents => 77500, :credit_applied_in_cents => 0 }}.to_xml
      
      FakeWeb.register_uri(:post, "#{test_domain}/subscriptions/#{id}/migrations/preview.xml?product_handle=upgraded-plan", :status => 201, :body => expected_response)
      
      response = Chargify::Migration::Preview.create(:subscription_id => subscription.id, :product_handle => 'upgraded-plan')

      expect(response.valid?).to be_true
      expect(response.errors.any?).to be_false
      expect(response).to be_a(Chargify::Migration::Preview)
    end
  end 
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
chargify_api_ares-1.0.1 spec/resources/migration_preview_spec.rb
chargify_api_ares-1.0.0 spec/resources/migration_preview_spec.rb