Improve classification specs' performance

This commit is contained in:
Arun Kumar Mohan
2020-09-26 16:26:44 -05:00
parent 362ab8a605
commit b850f10d2e

View File

@@ -2,11 +2,11 @@ require 'spec_helper'
module Spree
describe Classification do
let!(:product) { create(:simple_product) }
let!(:taxon) { create(:taxon) }
let(:classification) { create(:classification, taxon: taxon, product: product) }
let(:product) { build_stubbed(:simple_product) }
let(:taxon) { build_stubbed(:taxon) }
it "won't destroy if classification is the primary taxon" do
classification = Classification.new(taxon: taxon, product: product)
product.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"])