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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
322d6ead
Commit
322d6ead
authored
Mar 09, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Avoid locking yourself out when adding a GeoNode
parent
579370be
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
0 deletions
+19
-0
app/models/geo_node.rb
app/models/geo_node.rb
+9
-0
spec/models/geo_node_spec.rb
spec/models/geo_node_spec.rb
+10
-0
No files found.
app/models/geo_node.rb
View file @
322d6ead
...
...
@@ -72,4 +72,13 @@ class GeoNode < ActiveRecord::Base
def
change_geo_node_key_title
self
.
geo_node_key
.
title
=
"Geo node:
#{
self
.
url
}
"
if
self
.
geo_node_key
end
def
validate
(
record
)
# Prevent locking yourself out
if
record
.
host
==
Gitlab
.
config
.
gitlab
.
host
&&
record
.
port
==
Gitlab
.
config
.
gitlab
.
port
&&
record
.
relative_url_root
==
Gitlab
.
config
.
gitlab
.
relative_url_root
&&
!
record
.
primary
record
.
errors
[
:base
]
<<
'Current node must be the primary node or you will be locking yourself out'
end
end
end
spec/models/geo_node_spec.rb
View file @
322d6ead
...
...
@@ -32,6 +32,16 @@ describe GeoNode, type: :model do
end
end
context
'prevent locking yourself out'
do
subject
{
GeoNode
.
new
(
host:
Gitlab
.
config
.
gitlab
.
host
,
port:
Gitlab
.
config
.
gitlab
.
port
,
relative_url_root:
Gitlab
.
config
.
gitlab
.
relative_url_root
)
}
it
'does not accept adding a non primary node with same details as current_node'
do
expect
(
subject
).
not_to
be_valid
end
end
describe
'#uri'
do
context
'when all fields are filled'
do
subject
{
GeoNode
.
new
(
schema:
'https'
,
host:
'localhost'
,
port:
3000
,
relative_url_root:
'gitlab'
)
}
...
...
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