Skip to content

Commit

Permalink
12973: add specs
Browse files Browse the repository at this point in the history
  • Loading branch information
chahmedejaz committed Nov 28, 2024
1 parent 3836bf9 commit 5d6ac43
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions spec/models/product_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1012,6 +1012,30 @@
expect(lettuce.count_on_hand).to eq 96 # In different enterprise; unchanged
end
end

# Fix https://github.com/openfoodfoundation/openfoodnetwork/issues/12973
describe 'update existing product with units and on_hand/on_demand is empty' do
let(:csv_data) do
CSV.generate do |csv|
csv << ["name", "producer", "category", "on_hand", "price", "units", "unit_type",
"shipping_category", "on_demand"]
csv << ["Beetroot", enterprise3.name, "Vegetables", "", "6.50", "", "g",
shipping_category.name, "1"]
end
end
let(:importer) { import_data csv_data }

it "returns the units error due to invalid data" do
importer.validate_entries
entries = JSON.parse(importer.entries_json)

expect(entries.dig('2', 'errors')).to eq(
{
"units" => "Units can't be blank",
}
)
end
end
end

private
Expand Down

0 comments on commit 5d6ac43

Please sign in to comment.