Skip to content

Commit

Permalink
Fix error when importing entries with a tax category
Browse files Browse the repository at this point in the history
  • Loading branch information
Matt-Yorkley committed Sep 8, 2023
1 parent a096c56 commit 839e580
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
1 change: 0 additions & 1 deletion app/models/product_import/entry_validator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ def self.non_updatable_fields
description: :description,
unit_type: :variant_unit_scale,
variant_unit_name: :variant_unit_name,
tax_category: :tax_category_id,
}
end

Expand Down
26 changes: 26 additions & 0 deletions spec/models/product_importer_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -413,6 +413,32 @@
expect(filter('invalid', entries)).to eq 0
expect(filter('update_product', entries)).to eq 1
end

context "updating tax category" do
let(:csv_data) {
CSV.generate do |csv|
csv << ["name", "producer", "category", "on_hand", "price", "units",
"unit_type", "display_name", "shipping_category", "tax_category"]
csv << ["Hypothetical Cake", enterprise2.name, "Cake", "123", "123",
"500", "g", "Preexisting Banana", shipping_category.name, tax_category2.name]
end
}

it "allows updating tax category" do
importer.validate_entries

entries = JSON.parse(importer.entries_json)
expect(filter('valid', entries)).to eq 1
expect(filter('invalid', entries)).to eq 0
expect(filter('update_product', entries)).to eq 1

importer.save_entries

variant = Spree::Variant.find_by(display_name: "Preexisting Banana")
expect(variant.on_hand).to eq(123)
expect(variant.tax_category).to eq tax_category2
end
end
end

describe "updating variant having an nil display name with CSV with empty display name" do
Expand Down

0 comments on commit 839e580

Please sign in to comment.