BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
3576d59a
Commit
3576d59a
authored
Jan 09, 2018
by
Michael Kozono
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix Route validation for unchanged path"
This reverts commit
8040edcc
.
parent
48a018c6
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
61 deletions
+1
-61
route.rb
app/models/route.rb
+1
-1
route_spec.rb
spec/models/route_spec.rb
+0
-60
No files found.
app/models/route.rb
View file @
3576d59a
...
...
@@ -8,7 +8,7 @@ class Route < ActiveRecord::Base
presence:
true
,
uniqueness:
{
case_sensitive:
false
}
validate
:ensure_permanent_paths
,
if: :path_changed?
validate
:ensure_permanent_paths
after_create
:delete_conflicting_redirects
after_update
:delete_conflicting_redirects
,
if: :path_changed?
...
...
spec/models/route_spec.rb
View file @
3576d59a
...
...
@@ -16,66 +16,6 @@ describe Route do
it
{
is_expected
.
to
validate_presence_of
(
:source
)
}
it
{
is_expected
.
to
validate_presence_of
(
:path
)
}
it
{
is_expected
.
to
validate_uniqueness_of
(
:path
).
case_insensitive
}
describe
'#ensure_permanent_paths'
do
context
'when the route is not yet persisted'
do
let
(
:new_route
)
{
Route
.
new
(
path:
'foo'
,
source:
build
(
:group
))
}
context
'when permanent conflicting redirects exist'
do
it
'is invalid'
do
redirect
=
RedirectRoute
.
new
(
path:
'foo/bar/baz'
,
source:
create
(
:group
),
permanent:
true
)
redirect
.
save!
(
validate:
false
)
expect
(
new_route
.
valid?
).
to
be_falsey
expect
(
new_route
.
errors
.
first
[
1
]).
to
eq
(
'foo has been taken before. Please use another one'
)
end
end
context
'when no permanent conflicting redirects exist'
do
it
'is valid'
do
expect
(
new_route
.
valid?
).
to
be_truthy
end
end
end
context
'when path has changed'
do
before
do
route
.
path
=
'foo'
end
context
'when permanent conflicting redirects exist'
do
it
'is invalid'
do
redirect
=
RedirectRoute
.
new
(
path:
'foo/bar/baz'
,
source:
create
(
:group
),
permanent:
true
)
redirect
.
save!
(
validate:
false
)
expect
(
route
.
valid?
).
to
be_falsey
expect
(
route
.
errors
.
first
[
1
]).
to
eq
(
'foo has been taken before. Please use another one'
)
end
end
context
'when no permanent conflicting redirects exist'
do
it
'is valid'
do
expect
(
route
.
valid?
).
to
be_truthy
end
end
end
context
'when path has not changed'
do
context
'when permanent conflicting redirects exist'
do
it
'is valid'
do
redirect
=
RedirectRoute
.
new
(
path:
'git_lab/foo/bar'
,
source:
create
(
:group
),
permanent:
true
)
redirect
.
save!
(
validate:
false
)
expect
(
route
.
valid?
).
to
be_truthy
end
end
context
'when no permanent conflicting redirects exist'
do
it
'is valid'
do
expect
(
route
.
valid?
).
to
be_truthy
end
end
end
end
end
describe
'callbacks'
do
...
...
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