This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 76
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #48 from solidusio/transaction_import_state_advancing
Pass order state to transaction import
- Loading branch information
Showing
6 changed files
with
96 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,13 +3,27 @@ | |
RSpec.describe SolidusPaypalBraintree::TransactionsController, type: :controller do | ||
routes { SolidusPaypalBraintree::Engine.routes } | ||
|
||
include_context "order ready for payment" | ||
let!(:country) { create :country } | ||
let!(:state) { create :state, abbr: 'WA', country: country } | ||
let(:user) { create :user } | ||
let(:line_item) { create :line_item, price: 50 } | ||
let(:address) { create :address, country: country } | ||
let(:order) do | ||
Spree::Order.create!( | ||
line_items: [line_item], | ||
email: '[email protected]', | ||
bill_address: address, | ||
ship_address: address, | ||
user: user | ||
) | ||
end | ||
|
||
let(:payment_method) { create_gateway } | ||
|
||
before do | ||
allow(controller).to receive(:spree_current_user) { user } | ||
allow(controller).to receive(:current_order) { order } | ||
create :shipping_method, cost: 5 | ||
end | ||
|
||
cassette_options = { cassette_name: "transactions_controller/create" } | ||
|
@@ -58,6 +72,22 @@ | |
expect(order.payments.first.amount).to eq 55 | ||
end | ||
|
||
context "no end state is provided" do | ||
it "advances the order to confirm" do | ||
post_create | ||
expect(order).to be_confirm | ||
end | ||
end | ||
|
||
context "end state provided is delivery" do | ||
let(:params) { super().merge(state: 'delivery') } | ||
|
||
it "advances the order to delivery" do | ||
post_create | ||
expect(order).to be_delivery | ||
end | ||
end | ||
|
||
context "and an address is provided" do | ||
it "creates a new address" do | ||
# Creating the order also creates 3 addresses, we want to make sure | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters