Skip to content

Commit

Permalink
Merge pull request #29 from friendlycart/shipment-has-pallets
Browse files Browse the repository at this point in the history
Allow shipments to have pallets
  • Loading branch information
mamhoff authored Aug 2, 2023
2 parents e33fba5 + 7f659ed commit 91d49cc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
4 changes: 3 additions & 1 deletion lib/physical/shipment.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ class Shipment
:origin,
:destination,
:service_code,
:pallets,
:packages,
:options

def initialize(id: nil, origin: nil, destination: nil, service_code: nil, packages: [], options: {})
def initialize(id: nil, origin: nil, destination: nil, service_code: nil, pallets: [], packages: [], options: {})
@id = id || SecureRandom.uuid
@origin = origin
@destination = destination
@service_code = service_code
@pallets = pallets
@packages = packages
@options = options
end
Expand Down
1 change: 1 addition & 0 deletions lib/physical/spec_support/factories/shipment_factory.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
factory :physical_shipment, class: "Physical::Shipment" do
origin { FactoryBot.build(:physical_location) }
destination { FactoryBot.build(:physical_location) }
pallets { build_list(:physical_pallet, 1) }
packages { build_list(:physical_package, 2) }
service_code { "usps_priority_mail" }
initialize_with { new(**attributes) }
Expand Down
7 changes: 7 additions & 0 deletions spec/physical/shipment_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
let(:args) { {} }
subject(:shipment) { described_class.new(**args) }

describe '#pallets' do
subject { shipment.pallets }

it { is_expected.to eq([]) }
end

describe '#packages' do
subject { shipment.packages }

Expand Down Expand Up @@ -40,6 +46,7 @@
it "works" do
expect(subject.origin).to be_a(Physical::Location)
expect(subject.destination).to be_a(Physical::Location)
expect(subject.pallets.length).to eq(1)
expect(subject.packages.length).to eq(2)
expect(subject.service_code).to eq("usps_priority_mail")
end
Expand Down

0 comments on commit 91d49cc

Please sign in to comment.