Files
openfoodnetwork/spec/models/spree/classification_spec.rb
Matt-Yorkley ab4660ecd0 Fix callback in Classification and update spec
Fixes:

2) Spree::Classification won't destroy if classification is the primary taxon
(Used from /home/runner/work/openfoodnetwork/openfoodnetwork/spec/models/enterprise_group_spec.rb:43:in `block (3 levels) in <top (required)>')
     Failure/Error: expect(classification.destroy).to be false
2021-04-13 16:54:32 -07:00

20 lines
618 B
Ruby

# 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