From 03266921b563290368c08913f9c842433e7a92ba Mon Sep 17 00:00:00 2001 From: Sean Date: Thu, 22 Oct 2020 09:51:20 -0500 Subject: [PATCH] Fix api source view path The API source view is unable to be found in /api/source_views, it needs to be in api/payments/source_views instead. This PR changes the path to be correct, and adds a regression test. --- .../_paypal_braintree.json.jbuilder | 0 .../spree/api/orders_controller_spec.rb | 36 +++++++++++++++++++ 2 files changed, 36 insertions(+) rename app/views/spree/api/{ => payments}/source_views/_paypal_braintree.json.jbuilder (100%) create mode 100644 spec/requests/spree/api/orders_controller_spec.rb diff --git a/app/views/spree/api/source_views/_paypal_braintree.json.jbuilder b/app/views/spree/api/payments/source_views/_paypal_braintree.json.jbuilder similarity index 100% rename from app/views/spree/api/source_views/_paypal_braintree.json.jbuilder rename to app/views/spree/api/payments/source_views/_paypal_braintree.json.jbuilder diff --git a/spec/requests/spree/api/orders_controller_spec.rb b/spec/requests/spree/api/orders_controller_spec.rb new file mode 100644 index 00000000..ebb882e5 --- /dev/null +++ b/spec/requests/spree/api/orders_controller_spec.rb @@ -0,0 +1,36 @@ +require 'spec_helper' + +describe Spree::Api::OrdersController, type: :request do + stub_authorization! + + describe 'get show' do + let(:gateway) { create_gateway } + let(:order) { create(:order_with_line_items) } + let(:source) do + SolidusPaypalBraintree::Source.new( + nonce: 'fake-valid-nonce', + user: order.user, + payment_type: SolidusPaypalBraintree::Source::PAYPAL, + payment_method: gateway + ) + end + + context 'when using braintree as the payment' do + before do + allow_any_instance_of(Spree::Payment).to receive(:create_payment_profile).and_return(true) + + order.payments.create!( + payment_method: gateway, + source: source, + amount: 55 + ) + end + + it "can be rendered correctly" do + get "/api/orders/#{order.number}" + + expect(response.status).to eq 200 + end + end + end +end