mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-28 01:53:25 +00:00
Require associations of CoordinatorFee
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class CoordinatorFee < ApplicationRecord
|
||||
self.belongs_to_required_by_default = true
|
||||
|
||||
belongs_to :order_cycle
|
||||
belongs_to :enterprise_fee
|
||||
end
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class RequireOrderCycleAndEnterpriseFeeOnCoordinatorFees < ActiveRecord::Migration[7.0]
|
||||
def change
|
||||
change_column_null :coordinator_fees, :order_cycle_id, false
|
||||
change_column_null :coordinator_fees, :enterprise_fee_id, false
|
||||
end
|
||||
end
|
||||
@@ -64,8 +64,8 @@ ActiveRecord::Schema[7.0].define(version: 2023_05_22_120633) do
|
||||
end
|
||||
|
||||
create_table "coordinator_fees", id: :serial, force: :cascade do |t|
|
||||
t.integer "order_cycle_id"
|
||||
t.integer "enterprise_fee_id"
|
||||
t.integer "order_cycle_id", null: false
|
||||
t.integer "enterprise_fee_id", null: false
|
||||
t.index ["enterprise_fee_id"], name: "index_coordinator_fees_on_enterprise_fee_id"
|
||||
t.index ["order_cycle_id"], name: "index_coordinator_fees_on_order_cycle_id"
|
||||
end
|
||||
|
||||
8
spec/models/coordinator_fee_spec.rb
Normal file
8
spec/models/coordinator_fee_spec.rb
Normal file
@@ -0,0 +1,8 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
|
||||
describe CoordinatorFee do
|
||||
it { is_expected.to belong_to(:order_cycle).required }
|
||||
it { is_expected.to belong_to(:enterprise_fee).required }
|
||||
end
|
||||
Reference in New Issue
Block a user