Skip to content

Instantly share code, notes, and snippets.

@cored
Created February 12, 2018 21:12
Show Gist options
  • Save cored/bf8c1f2bcddbf08d60b39f3be0d3ca47 to your computer and use it in GitHub Desktop.
Save cored/bf8c1f2bcddbf08d60b39f3be0d3ca47 to your computer and use it in GitHub Desktop.
require "dry-struct"
require_relative "../../../../../app/services/inventory/flexe/types"
require_relative "../../../../../app/services/inventory/flexe/deliveries/container_delivery_details"
describe Inventory::Flexe::Deliveries::ContainerDeliveryDetails do
let(:container_delivery_details_attrs) do
{
shipment_id: "1",
shipment_type: "container_delivery",
reservation_id: "34543",
status: "in_transit",
container_delivery_details: {
purchase_order: "2039423",
container_number: "T2340234",
seal_number: "1932465465",
vendor: "Johnson",
expected_inventory: [
{ sku: "DH-3942", quantity: 23, unit: "each" },
{ sku: "XFG-0192", quantity: 300, unit: "each" },
{ sku: "IO-90002", quantity: 5, unit: "carton" },
],
received_inventory: [
{ sku: "DH-3942", quantity: 23, unit: "each" },
{ sku: "XFG-0192", quantity: 300, unit: "each" },
{ sku: "IO-90002", quantity: 3, unit: "carton" },
],
damaged_inventory: [
{ sku: "IO-90002", quantity: 2, unit: "carton" },
],
quantities_by_inventory: {
"DH-3942": {
expected: {
pallet: { amount: 1, unit: "pallet" },
carton: { amount: 23, unit: "carton" },
each: { amount: 23, unit: "each" },
},
received: {
pallet: { amount: 1, unit: "pallet" },
carton: { amount: 23, unit: "carton" },
each: { amount: 23, unit: "each" },
},
damaged: {
pallet: { amount: 0, unit: "pallet" },
carton: { amount: 0, unit: "carton" },
each: { amount: 0, unit: "each" },
},
},
"XFG-0192": {
expected: {
pallet: { amount: 3, unit: "pallet" },
carton: { amount: 10, unit: "carton" },
each: { amount: 300, unit: "each" },
},
received: {
pallet: { amount: 3, unit: "pallet" },
carton: { amount: 10, unit: "carton" },
each: { amount: 300, unit: "each" },
},
damaged: {
pallet: { amount: 0, unit: "pallet" },
carton: { amount: 0, unit: "carton" },
each: { amount: 0, unit: "each" },
},
},
"IO-90002": {
expected: {
pallet: { amount: 0, unit: "pallet" },
carton: { amount: 5, unit: "carton" },
},
received: {
pallet: { amount: 0, unit: "pallet" },
carton: { amount: 3, unit: "carton" },
},
damaged: {
pallet: { amount: 0, unit: "pallet" },
carton: { amount: 2, unit: "carton" },
},
},
},
},
}
end
describe "#row_names" do
it "returns the proper row names" do
expect(
described_class.for(container_delivery_details_attrs).row_names
).to eql(%i[
sku
quantity
unit
shipment_id
shipment_type
reservation_id
status
purchase_order
container_number
seal_number
vendor
])
end
end
describe "#row_values" do
it "returns the proper values for each row" do
expect(
described_class.for(container_delivery_details_attrs).row_values
).to eql([
[
"DH-3942",
23,
"each",
"1",
"container_delivery",
"34543",
"in_transit",
"2039423",
"T2340234",
"1932465465",
"Johnson",
],
[
"XFG-0192",
300,
"each",
"1",
"container_delivery",
"34543",
"in_transit",
"2039423",
"T2340234",
"1932465465",
"Johnson",
],
[
"IO-90002",
0,
"each",
"1",
"container_delivery",
"34543",
"in_transit",
"2039423",
"T2340234",
"1932465465",
"Johnson",
],
])
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment