-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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 #3005 from nebulab/cedum/enable_verify_partial_dou…
…bles Enable partial doubles verification for RSpec
- Loading branch information
Showing
20 changed files
with
79 additions
and
93 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
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 |
---|---|---|
|
@@ -36,7 +36,7 @@ def assert_state_changed(order, from, to) | |
Spree::Order.checkout_flow(&@old_checkout_flow) | ||
end | ||
|
||
it '.remove_transition' do | ||
it '.remove_transition', partial_double_verification: false do | ||
options = { from: transitions.first.keys.first, to: transitions.first.values.first } | ||
allow(Spree::Order).to receive(:next_event_transition).and_return([options]) | ||
expect(Spree::Order.remove_transition(options)).to be_truthy | ||
|
@@ -238,7 +238,7 @@ def assert_state_changed(order, from, to) | |
order.ship_address = ship_address | ||
end | ||
|
||
context 'when order has default selected_shipping_rate_id' do | ||
context 'when order has default selected_shipping_rate_id', partial_double_verification: false do | ||
let(:shipment) { create(:shipment, order: order) } | ||
let(:shipping_method) { create(:shipping_method) } | ||
let(:shipping_rate) { | ||
|
@@ -277,7 +277,7 @@ def assert_state_changed(order, from, to) | |
end | ||
end | ||
|
||
context "from delivery" do | ||
context "from delivery", partial_double_verification: false do | ||
let(:ship_address) { FactoryBot.create(:ship_address) } | ||
|
||
before do | ||
|
@@ -537,7 +537,7 @@ def assert_state_changed(order, from, to) | |
end | ||
end | ||
|
||
context "default credit card" do | ||
context "default credit card", partial_double_verification: false do | ||
before do | ||
order.user = FactoryBot.create(:user) | ||
order.store = FactoryBot.create(:store) | ||
|
@@ -568,7 +568,7 @@ def assert_state_changed(order, from, to) | |
end | ||
end | ||
|
||
context "a payment fails during processing" do | ||
context "a payment fails during processing", partial_double_verification: false do | ||
before do | ||
order.user = FactoryBot.create(:user) | ||
order.email = '[email protected]' | ||
|
@@ -656,7 +656,7 @@ def assert_state_changed(order, from, to) | |
assert_state_changed(order, 'cart', 'complete') | ||
end | ||
|
||
it "does not attempt to process payments" do | ||
it "does not attempt to process payments", partial_double_verification: false do | ||
order.email = '[email protected]' | ||
allow(order).to receive(:ensure_promotions_eligible).and_return(true) | ||
allow(order).to receive(:ensure_line_item_variants_are_not_deleted).and_return(true) | ||
|
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,11 +3,8 @@ | |
require 'rails_helper' | ||
|
||
RSpec.describe Spree::Order, type: :model do | ||
let(:order) { stub_model("Spree::Order") } | ||
|
||
context "#finalize!" do | ||
let!(:store) { create(:store) } | ||
let(:order) { Spree::Order.create(email: '[email protected]', store: store) } | ||
let(:order) { create(:order_ready_to_complete) } | ||
|
||
before do | ||
order.update_column :state, 'complete' | ||
|
@@ -26,29 +23,13 @@ | |
order.finalize! | ||
end | ||
|
||
it "should decrease the stock for each variant in the shipment" do | ||
order.shipments.each do |shipment| | ||
expect(shipment.stock_location).to receive(:decrease_stock_for_variant) | ||
end | ||
order.finalize! | ||
end | ||
|
||
it "should change the shipment state to ready if order is paid" do | ||
Spree::Shipment.create(order: order) | ||
order.shipments.reload | ||
|
||
allow(order).to receive_messages(paid?: true, complete?: true) | ||
order.finalize! | ||
order.reload # reload so we're sure the changes are persisted | ||
expect(order.shipment_state).to eq('ready') | ||
end | ||
|
||
it "should not sell inventory units if track_inventory_levels is false" do | ||
Spree::Config.set track_inventory_levels: false | ||
expect(Spree::InventoryUnit).not_to receive(:sell_units) | ||
order.finalize! | ||
end | ||
|
||
it "should send an order confirmation email" do | ||
mail_message = double "Mail::Message" | ||
expect(Spree::OrderMailer).to receive(:confirm_email).with(order).and_return mail_message | ||
|
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
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
Oops, something went wrong.