Make enterprise mandatory for a voucher

It should have already been the case...
This commit is contained in:
Gaetan Craig-Riou
2023-05-05 16:14:21 +10:00
committed by Maikel Linke
parent 2d8fa24862
commit b585f77be4
3 changed files with 4 additions and 3 deletions

View File

@@ -3,7 +3,7 @@
class Voucher < ApplicationRecord
acts_as_paranoid
belongs_to :enterprise
belongs_to :enterprise, optional: false
has_many :adjustments,
as: :originator,

View File

@@ -1432,6 +1432,8 @@ describe Spree::Order do
end
describe "#voucher_adjustments" do
let(:distributor) { create(:distributor_enterprise) }
let(:order) { create(:order, user: user, distributor: distributor) }
let(:voucher) { create(:voucher, code: 'new_code', enterprise: order.distributor) }
context "when no voucher adjustment" do
@@ -1441,7 +1443,6 @@ describe Spree::Order do
end
it "returns an array of voucher adjusment" do
order.save!
expected_adjustments = Array.new(2) { voucher.create_adjustment(voucher.code, order) }
expect(order.voucher_adjustments).to eq(expected_adjustments)

View File

@@ -6,7 +6,7 @@ describe Voucher do
let(:enterprise) { build(:enterprise) }
describe 'associations' do
it { is_expected.to belong_to(:enterprise) }
it { is_expected.to belong_to(:enterprise).required }
it { is_expected.to have_many(:adjustments) }
end