Skip to content

Commit

Permalink
Merge pull request #151 from barberj/barberj/package-code-dimensions-bug
Browse files Browse the repository at this point in the history
Include Dimensions regardless of package_code
  • Loading branch information
mamhoff authored Jan 19, 2023
2 parents 7d9b64e + c1866ca commit c71d408
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,13 @@ def serialize_packages(packages, options)
["reference#{index + 1}".to_sym, message]
end.to_h

if package_options.package_code
package_hash[:package_code] = package_options.package_code
else
package_hash[:dimensions] = {
unit: 'inch',
width: package.container.width.convert_to(:inches).value.to_f.round(2),
length: package.container.length.convert_to(:inches).value.to_f.round(2),
height: package.container.height.convert_to(:inches).value.to_f.round(2)
}
end
package_hash[:package_code] = package_options.package_code
package_hash[:dimensions] = {
unit: 'inch',
width: package.container.width.convert_to(:inches).value.to_f.round(2),
length: package.container.length.convert_to(:inches).value.to_f.round(2),
height: package.container.height.convert_to(:inches).value.to_f.round(2)
}
package_hash
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,12 @@
]
end

it 'does not include the dimensions array' do
it 'still includes the dimensions array' do
is_expected.to match(
hash_including(
shipment: hash_including(
packages: array_including(
hash_not_including(:dimensions)
hash_including(:dimensions)
)
)
)
Expand Down

0 comments on commit c71d408

Please sign in to comment.