Update taxon specs

This commit is contained in:
Matt-Yorkley
2023-08-07 15:05:59 +01:00
parent 33d40ed750
commit 8d01e1f024
3 changed files with 4 additions and 26 deletions

View File

@@ -677,8 +677,8 @@ describe Enterprise do
let(:taxon1) { create(:taxon) }
let(:taxon2) { create(:taxon) }
let(:taxon3) { create(:taxon) }
let(:product1) { create(:simple_product, primary_taxon: taxon1, taxons: [taxon1]) }
let(:product2) { create(:simple_product, primary_taxon: taxon1, taxons: [taxon1, taxon2]) }
let(:product1) { create(:simple_product, primary_taxon: taxon1) }
let(:product2) { create(:simple_product, primary_taxon: taxon2) }
let(:product3) { create(:simple_product, primary_taxon: taxon3) }
let(:oc) { create(:order_cycle) }
let(:ex) {

View File

@@ -1,22 +0,0 @@
# frozen_string_literal: true
require 'spec_helper'
module Spree
describe Classification do
let(:product) { create(:simple_product) }
let(:taxon) { create(:taxon) }
it "won't destroy if classification is the primary taxon" do
classification = Classification.create(taxon: taxon, product: product)
product.update(primary_taxon: taxon)
expect(classification.destroy).to be false
expect(classification.errors.messages[:base])
.to eq(
["Taxon #{taxon.name} is the primary taxon of #{product.name} and cannot be deleted"]
)
expect(classification.reload).to be
end
end
end

View File

@@ -11,10 +11,10 @@ module Spree
let(:t2) { create(:taxon) }
describe "finding all supplied taxons" do
let!(:p1) { create(:simple_product, supplier: e, taxons: [t1, t2]) }
let!(:p1) { create(:simple_product, supplier: e, primary_taxon_id: t1.id) }
it "finds taxons" do
expect(Taxon.supplied_taxons).to eq(e.id => Set.new(p1.taxons.map(&:id)))
expect(Taxon.supplied_taxons).to eq(e.id => Set.new([t1.id]))
end
end