mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Update taxon specs
This commit is contained in:
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user