Require account registrar to be present

#475
This commit is contained in:
Artur Beljajev 2017-05-07 00:26:32 +03:00
parent ae64c7cbed
commit 3162c76bbf
2 changed files with 13 additions and 2 deletions

View file

@ -1,6 +1,7 @@
class Account < ActiveRecord::Base
include Versions
belongs_to :registrar
belongs_to :registrar, required: true
has_many :account_activities
validates :account_type, presence: true

View file

@ -1,6 +1,6 @@
require 'rails_helper'
describe Account do
RSpec.describe Account do
context 'with invalid attribute' do
before :all do
@account = Account.new
@ -45,4 +45,14 @@ describe Account do
end
end
end
describe 'registrar validation', db: false do
subject(:account) { described_class.new }
it 'rejects absent' do
account.registrar = nil
account.validate
expect(account.errors).to have_key(:registrar)
end
end
end