From a571f7600dc0a60c0ef12db8afde8f66a0e7e23e Mon Sep 17 00:00:00 2001 From: Alex Kotov Date: Sat, 15 Dec 2018 10:54:45 +0500 Subject: [PATCH] Make Person#regional_office optional --- app/models/person.rb | 2 +- spec/models/person_spec.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/models/person.rb b/app/models/person.rb index cbc3c8f..de6037b 100644 --- a/app/models/person.rb +++ b/app/models/person.rb @@ -1,7 +1,7 @@ # frozen_string_literal: true class Person < ApplicationRecord - belongs_to :regional_office + belongs_to :regional_office, optional: true has_one :account, dependent: :restrict_with_exception diff --git a/spec/models/person_spec.rb b/spec/models/person_spec.rb index c1fcb29..8bce052 100644 --- a/spec/models/person_spec.rb +++ b/spec/models/person_spec.rb @@ -5,7 +5,7 @@ require 'rails_helper' RSpec.describe Person do subject { create :person } - it { is_expected.to belong_to(:regional_office) } + it { is_expected.to belong_to(:regional_office).optional } it { is_expected.to have_one(:account).dependent(:restrict_with_exception) }