1
0
Fork 0

Rename association Person#relationships to #all_relationships

This commit is contained in:
Alex Kotov 2019-07-20 17:16:48 +05:00
parent 0f2500fd0d
commit 22d55052f3
Signed by: kotovalexarian
GPG key ID: 553C0EBBEB5D5F08
4 changed files with 10 additions and 6 deletions

View file

@ -11,8 +11,9 @@ class Person < ApplicationRecord
has_one :account
has_many :relationships,
has_many :all_relationships,
-> { order(from_date: :asc) },
class_name: 'Relationship',
inverse_of: :person
has_one :current_relationship,

View file

@ -9,7 +9,7 @@ class Relationship < ApplicationRecord
# Associations #
################
belongs_to :person, inverse_of: :relationships
belongs_to :person, inverse_of: :all_relationships
belongs_to :regional_office, inverse_of: :all_relationships

View file

@ -15,7 +15,7 @@ RSpec.describe Person do
xit { is_expected.to belong_to(:contacts_list).required }
end
describe '#relationships' do
describe '#all_relationships' do
let! :relationship_2 do
create :supporter_relationship,
person: subject,
@ -36,14 +36,15 @@ RSpec.describe Person do
it do
is_expected.to \
have_many(:relationships)
have_many(:all_relationships)
.class_name('Relationship')
.inverse_of(:person)
.dependent(:restrict_with_exception)
.order(from_date: :asc)
end
specify do
expect(subject.relationships).to eq [
expect(subject.all_relationships).to eq [
relationship_1,
relationship_2,
relationship_3,

View file

@ -6,7 +6,9 @@ RSpec.describe Relationship do
subject { create :supporter_relationship }
describe '#person' do
it { is_expected.to belong_to(:person).inverse_of(:relationships).required }
it do
is_expected.to belong_to(:person).inverse_of(:all_relationships).required
end
end
describe '#regional_office' do