BigW Consortium Gitlab

Commit b552a4eb by Dmitriy Zaporozhets

Validate presence of route by Routable concern

parent 3f768f9a
...@@ -7,6 +7,7 @@ module Routable ...@@ -7,6 +7,7 @@ module Routable
has_one :route, as: :source, autosave: true, dependent: :destroy has_one :route, as: :source, autosave: true, dependent: :destroy
validates_associated :route validates_associated :route
validates :route, presence: true
before_validation :update_route_path, if: :full_path_changed? before_validation :update_route_path, if: :full_path_changed?
end end
......
...@@ -3,6 +3,10 @@ require 'spec_helper' ...@@ -3,6 +3,10 @@ require 'spec_helper'
describe Group, 'Routable' do describe Group, 'Routable' do
let!(:group) { create(:group) } let!(:group) { create(:group) }
describe 'Validations' do
it { is_expected.to validate_presence_of(:route) }
end
describe 'Associations' do describe 'Associations' do
it { is_expected.to have_one(:route).dependent(:destroy) } it { is_expected.to have_one(:route).dependent(:destroy) }
end end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment