Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
b552a4eb
Commit
b552a4eb
authored
Dec 07, 2016
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Validate presence of route by Routable concern
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
3f768f9a
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
5 additions
and
0 deletions
+5
-0
app/models/concerns/routable.rb
app/models/concerns/routable.rb
+1
-0
spec/models/concerns/routable_spec.rb
spec/models/concerns/routable_spec.rb
+4
-0
No files found.
app/models/concerns/routable.rb
View file @
b552a4eb
...
@@ -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
...
...
spec/models/concerns/routable_spec.rb
View file @
b552a4eb
...
@@ -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
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment