Optimise spec

This commit is contained in:
David Cook
2023-09-19 13:39:36 +10:00
parent e7a52e4733
commit fb93aeb195

View File

@@ -291,7 +291,7 @@ describe Admin::EnterprisesController, type: :controller do
describe "vouchers" do
let(:enterprise) { create(:distributor_enterprise) }
let!(:voucher_a) { create(:voucher, enterprise: enterprise, code: "voucher 1") }
let!(:voucher_b) { create(:voucher, enterprise: enterprise, code: "voucher 2") }
let(:voucher_b) { create(:voucher, enterprise: enterprise, code: "voucher 2") }
before do
controller_login_as_enterprise_user [enterprise]
@@ -319,10 +319,8 @@ describe Admin::EnterprisesController, type: :controller do
expect(voucher_a.reload.deleted?).to be(true)
end
context "when desactivating the only existing voucher" do
context "when deactivating the only existing voucher" do
it "deactivates the voucher" do
voucher_b.really_destroy!
# Rails won't populate vouchers_id params if no voucher selected
spree_put :update,
id: enterprise,
@@ -334,6 +332,7 @@ describe Admin::EnterprisesController, type: :controller do
context "when activating and deactivating voucher at the same time" do
it "deactivates and activates accordingly" do
voucher_b
voucher_c = create(:voucher, enterprise: enterprise, code: "voucher 3")
voucher_c.destroy