spec/ecommerce/resources/order_spec.rb in ecommerce-client-0.0.2 vs spec/ecommerce/resources/order_spec.rb in ecommerce-client-0.0.3
- old
+ new
@@ -142,14 +142,55 @@
expect{ subject }.to raise_error(Ecommerce::RequestError)
end
end
end
- describe '#destroy' do
- subject { described_class.new({ number: 2609, plan_slug: 'rexpense-custom-monthly-brl-5250' }) }
+ describe '.update', vcr: true do
+ let(:params) { { document_number: "976.305.273-49", identity: "8923199e-6c43-415a-bbd1-2e302fdf8d96", client_email: "jaime.lannister@mailinator.com", client_name: "Jaime Lannister KingSlayer" } }
- it 'invokes Ecommerce::Resources::Order.destroy' do
- expect(Ecommerce::Resources::Order).to receive(:destroy).with(2609, 'rexpense-custom-monthly-brl-5250')
- subject.destroy
+ subject { described_class.update(2608, "rexpense-custom-monthly-brl-5250", params) }
+
+ context 'with success' do
+ it 'returns order information on body' do
+ expect(subject.is_paid).to be_falsy
+ expect(subject.address_number).to be_nil
+ expect(subject.plan_change_urls).to eq({"rexpense-beta"=>"http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2608/change/rexpense-beta/"})
+ expect(subject.activation_expired).to be_falsy
+ expect(subject.number).to eq(2608)
+ expect(subject.address_state).to eq('')
+ expect(subject.global_account).to eq('e5732007-7989-4372-8e72-9ec8cf6ee046')
+ expect(subject.api_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/")
+ expect(subject.is_trial).to be_falsy
+ expect(subject.document_number).to eq("97630527349")
+ expect(subject.checkout_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/rexpense-custom-monthly-brl-5250/2608/checkout/")
+ expect(subject.active_until).to be_nil
+ expect(subject.charge_day).to eq(25)
+ expect(subject.address_quarter).to be_nil
+ expect(subject.activated_at).to be_nil
+ expect(subject.is_active).to be_falsy
+ expect(subject.user_code).to be_empty
+ expect(subject.address).to be_nil
+ expect(subject.is_recurring).to be_truthy
+ expect(subject.address_city).to be_nil
+ expect(subject.plan_slug).to eq("rexpense-custom-monthly-brl-5250")
+ expect(subject.address_complement).to eq('')
+ expect(subject.discounts_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/discounts/")
+ expect(subject.created_at).to eq(DateTime.new(2015, 3, 25, 17, 54, 42))
+ expect(subject.adjustments_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/adjustments/")
+ expect(subject.next_payment_at).to be_nil
+ expect(subject.amount).to eq(52.5)
+ expect(subject.client_email).to eq("jaime.lannister@mailinator.com")
+ expect(subject.zip_code).to be_nil
+ expect(subject.client_name).to eq("Jaime Lannister KingSlayer")
+ expect(subject.invoices_url).to eq("http://sandbox.ecommerce.myfreecomm.com.br/api/orders/rexpense-custom-monthly-brl-5250/2608/invoices/")
+ end
+ end
+
+ context 'when sending not all required parameters' do
+ before { params.delete(:document_number) }
+
+ it 'raises error BarRequest' do
+ expect{ subject }.to raise_error(Ecommerce::RequestError)
+ end
end
end
end