Files
openfoodnetwork/spec/controllers/spree/paypal_controller_spec.rb
Luis Ramos 8a9dae0ee2 Run rubocop autocorrect
This is the result of bundle exec rubocop --auto-correct
2020-06-22 12:23:10 +01:00

45 lines
1.3 KiB
Ruby

# frozen_string_literal: true
require 'spec_helper'
module Spree
describe PaypalController, type: :controller do
context 'when cancelling' do
it 'redirects back to checkout' do
expect(spree_get(:cancel)).to redirect_to checkout_path
end
end
context 'when confirming' do
let(:previous_order) { controller.current_order(true) }
let(:payment_method) { create(:payment_method) }
before do
allow(previous_order).to receive(:complete?).and_return(true)
end
it 'resets the order' do
spree_post :confirm, payment_method_id: payment_method.id
expect(controller.current_order).not_to eq(previous_order)
end
it 'sets the access token of the session' do
spree_post :confirm, payment_method_id: payment_method.id
expect(session[:access_token]).to eq(controller.current_order.token)
end
end
describe '#expire_current_order' do
it 'empties the order_id of the session' do
expect(session).to receive(:[]=).with(:order_id, nil)
controller.expire_current_order
end
it 'resets the @current_order ivar' do
controller.expire_current_order
expect(controller.instance_variable_get(:@current_order)).to be_nil
end
end
end
end