Fix bulk line items controller specs

This commit is contained in:
Gaetan Craig-Riou
2024-03-05 11:37:46 +11:00
parent ef298e3b62
commit 765655ae25

View File

@@ -95,29 +95,26 @@ RSpec.describe Admin::BulkLineItemsController, type: :controller do
let(:coordinator) { create(:distributor_enterprise) }
let(:order_cycle) { create(:simple_order_cycle, coordinator:) }
let!(:order1) {
FactoryBot.create(:order, order_cycle:, state: 'complete',
completed_at: Time.zone.now, distributor: distributor1,
billing_address: FactoryBot.create(:address) )
create(:order, order_cycle:, state: 'complete',
completed_at: Time.zone.now, distributor: distributor1,
billing_address: create(:address) )
}
let!(:line_item1) {
FactoryBot.create(:line_item_with_shipment, order: order1,
product: FactoryBot.create(:product,
supplier:))
create(:line_item_with_shipment, order: order1,
variant: create(:variant, supplier:))
}
let!(:line_item2) {
FactoryBot.create(:line_item_with_shipment, order: order1,
product: FactoryBot.create(:product,
supplier:))
create(:line_item_with_shipment, order: order1,
variant: create(:variant, supplier:))
}
let!(:order2) {
FactoryBot.create(:order, order_cycle:, state: 'complete',
completed_at: Time.zone.now, distributor: distributor2,
billing_address: FactoryBot.create(:address) )
create(:order, order_cycle:, state: 'complete',
completed_at: Time.zone.now, distributor: distributor2,
billing_address: create(:address) )
}
let!(:line_item3) {
FactoryBot.create(:line_item_with_shipment, order: order2,
product: FactoryBot.create(:product,
supplier:))
create(:line_item_with_shipment, order: order2,
variant: create(:variant, supplier:))
}
context "producer enterprise" do
@@ -189,15 +186,15 @@ RSpec.describe Admin::BulkLineItemsController, type: :controller do
let(:coordinator) { create(:distributor_enterprise) }
let(:order_cycle) { create(:simple_order_cycle, coordinator:) }
let!(:order1) {
FactoryBot.create(:order, order_cycle:, state: 'complete',
completed_at: Time.zone.now,
distributor: distributor1,
billing_address: FactoryBot.create(:address) )
create(:order, order_cycle:, state: 'complete',
completed_at: Time.zone.now,
distributor: distributor1,
billing_address: create(:address) )
}
let!(:line_item1) {
line_item1 = FactoryBot.create(:line_item_with_shipment,
order: order1,
product: FactoryBot.create(:product, supplier:))
line_item1 = create(:line_item_with_shipment,
order: order1,
variant: create(:variant, supplier:))
# make sure shipment is available through db reloads of this line_item
line_item1.tap(&:save!)
}
@@ -298,14 +295,13 @@ RSpec.describe Admin::BulkLineItemsController, type: :controller do
let(:coordinator) { create(:distributor_enterprise) }
let(:order_cycle) { create(:simple_order_cycle, coordinator:) }
let!(:order1) {
FactoryBot.create(:order, order_cycle:, state: 'complete',
completed_at: Time.zone.now, distributor: distributor1,
billing_address: FactoryBot.create(:address) )
create(:order, order_cycle:, state: 'complete',
completed_at: Time.zone.now, distributor: distributor1,
billing_address: create(:address) )
}
let!(:line_item1) {
FactoryBot.create(:line_item_with_shipment, order: order1,
product: FactoryBot.create(:product,
supplier:))
create(:line_item_with_shipment, order: order1,
variant: create(:variant, supplier:))
}
let(:params) { { id: line_item1.id, order_id: order1.number } }