Validate presence of route by Routable concern
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
This commit is contained in:
parent
3f768f9a14
commit
b552a4eb18
|
@ -7,6 +7,7 @@ module Routable
|
|||
has_one :route, as: :source, autosave: true, dependent: :destroy
|
||||
|
||||
validates_associated :route
|
||||
validates :route, presence: true
|
||||
|
||||
before_validation :update_route_path, if: :full_path_changed?
|
||||
end
|
||||
|
|
|
@ -3,6 +3,10 @@ require 'spec_helper'
|
|||
describe Group, 'Routable' do
|
||||
let!(:group) { create(:group) }
|
||||
|
||||
describe 'Validations' do
|
||||
it { is_expected.to validate_presence_of(:route) }
|
||||
end
|
||||
|
||||
describe 'Associations' do
|
||||
it { is_expected.to have_one(:route).dependent(:destroy) }
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue