mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-26 01:33:22 +00:00
Require EnterpriseFee.belongs_to by default
This commit is contained in:
@@ -3,10 +3,12 @@
|
||||
class EnterpriseFee < ApplicationRecord
|
||||
include CalculatedAdjustments
|
||||
|
||||
self.belongs_to_required_by_default = true
|
||||
|
||||
acts_as_paranoid
|
||||
|
||||
belongs_to :enterprise
|
||||
belongs_to :tax_category, class_name: 'Spree::TaxCategory'
|
||||
belongs_to :tax_category, optional: true, class_name: 'Spree::TaxCategory'
|
||||
|
||||
has_many :coordinator_fees, dependent: :destroy
|
||||
has_many :order_cycles, through: :coordinator_fees
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RequireEnterpriseOnEnterpriseFee < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
change_column_null :enterprise_fees, :enterprise_id, false
|
||||
end
|
||||
end
|
||||
@@ -121,7 +121,7 @@ ActiveRecord::Schema[7.0].define(version: 2023_08_09_201542) do
|
||||
end
|
||||
|
||||
create_table "enterprise_fees", id: :serial, force: :cascade do |t|
|
||||
t.integer "enterprise_id"
|
||||
t.integer "enterprise_id", null: false
|
||||
t.string "fee_type", limit: 255
|
||||
t.string "name", limit: 255
|
||||
t.datetime "created_at", precision: nil, null: false
|
||||
|
||||
@@ -4,7 +4,7 @@ require 'spec_helper'
|
||||
|
||||
describe EnterpriseFee do
|
||||
describe "associations" do
|
||||
it { is_expected.to belong_to(:enterprise) }
|
||||
it { is_expected.to belong_to(:enterprise).required }
|
||||
end
|
||||
|
||||
describe "validations" do
|
||||
|
||||
Reference in New Issue
Block a user