-
-
Notifications
You must be signed in to change notification settings - Fork 484
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create Standard Court Order per organization basis [#5781]
- Loading branch information
1 parent
8a1e07a
commit 4ab59e3
Showing
5 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
class StandardCourtOrder < ApplicationRecord | ||
belongs_to :casa_org | ||
|
||
validates :value, uniqueness: {scope: :casa_org_id, case_sensitive: false}, presence: true | ||
end | ||
|
||
# == Schema Information | ||
# | ||
# Table name: standard_court_orders | ||
# | ||
# id :bigint not null, primary key | ||
# value :string | ||
# created_at :datetime not null | ||
# updated_at :datetime not null | ||
# casa_org_id :bigint not null | ||
# | ||
# Indexes | ||
# | ||
# index_standard_court_orders_on_casa_org_id (casa_org_id) | ||
# | ||
# Foreign Keys | ||
# | ||
# fk_rails_... (casa_org_id => casa_orgs.id) | ||
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateStandardCourtOrders < ActiveRecord::Migration[7.1] | ||
def change | ||
create_table :standard_court_orders do |t| | ||
t.string :value | ||
t.references :casa_org, null: false, foreign_key: true | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FactoryBot.define do | ||
factory :standard_court_order do | ||
value { "Some standard court order" } | ||
casa_org { CasaOrg.first || create(:casa_org) } | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'rails_helper' | ||
|
||
RSpec.describe StandardCourtOrder, type: :model do | ||
describe 'associations' do | ||
it { is_expected.to belong_to(:casa_org) } | ||
end | ||
|
||
describe 'validations' do | ||
subject { FactoryBot.build(:standard_court_order) } | ||
|
||
it { is_expected.to validate_presence_of(:value) } | ||
it { is_expected.to validate_uniqueness_of(:value).scoped_to(:casa_org_id).case_insensitive } | ||
end | ||
end |