Add associations
This commit is contained in:
parent
220063b670
commit
ef000436dc
4 changed files with 15 additions and 1 deletions
|
@ -5,6 +5,8 @@ class Passport < ApplicationRecord
|
|||
|
||||
has_one_attached :image
|
||||
|
||||
has_many :passport_confirmations, dependent: :restrict_with_exception
|
||||
|
||||
validates :surname, presence: true
|
||||
validates :given_name, presence: true
|
||||
validates :sex, presence: true
|
||||
|
|
|
@ -15,4 +15,6 @@ class User < ApplicationRecord
|
|||
)
|
||||
|
||||
rolify role_join_table_name: 'user_roles'
|
||||
|
||||
has_many :passport_confirmations, dependent: :restrict_with_exception
|
||||
end
|
||||
|
|
|
@ -5,6 +5,12 @@ require 'rails_helper'
|
|||
RSpec.describe Passport do
|
||||
subject { create :passport }
|
||||
|
||||
it do
|
||||
is_expected.to \
|
||||
have_many(:passport_confirmations)
|
||||
.dependent(:restrict_with_exception)
|
||||
end
|
||||
|
||||
it { is_expected.to validate_presence_of :surname }
|
||||
it { is_expected.to validate_presence_of :given_name }
|
||||
it { is_expected.not_to validate_presence_of :patronymic }
|
||||
|
|
|
@ -5,5 +5,9 @@ require 'rails_helper'
|
|||
RSpec.describe User do
|
||||
subject { create :user }
|
||||
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
it do
|
||||
is_expected.to \
|
||||
have_many(:passport_confirmations)
|
||||
.dependent(:restrict_with_exception)
|
||||
end
|
||||
end
|
||||
|
|
Reference in a new issue