Files
openfoodnetwork/spec/models/voucher_spec.rb
Gaetan Craig-Riou a48fd0828c Add Voucher model
A voucher belongs to an enterprise and an enterprise can have many
vouchers
2023-03-28 13:39:29 +11:00

19 lines
449 B
Ruby

# frozen_string_literal: true
require 'spec_helper'
describe Voucher do
describe 'associations' do
it { is_expected.to belong_to(:enterprise) }
end
describe 'validations' do
subject { Voucher.new(code: 'new_code', enterprise: enterprise) }
let(:enterprise) { build(:enterprise) }
it { is_expected.to validate_presence_of(:code) }
it { is_expected.to validate_uniqueness_of(:code).scoped_to(:enterprise_id) }
end
end