Require associations of CoordinatorFee

This commit is contained in:
Maikel Linke
2023-05-16 15:31:50 +10:00
parent c02c90317f
commit fc00a48d67
4 changed files with 20 additions and 2 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View 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