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
a9095fcc
Commit
a9095fcc
authored
Apr 14, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved GeoNode specs and small fix
🍺
parent
7ad4d842
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
10 deletions
+18
-10
app/models/geo_node.rb
app/models/geo_node.rb
+2
-2
spec/models/geo_node_spec.rb
spec/models/geo_node_spec.rb
+16
-8
No files found.
app/models/geo_node.rb
View file @
a9095fcc
...
...
@@ -22,7 +22,7 @@ class GeoNode < ActiveRecord::Base
primary:
false
,
token:
lambda
{
SecureRandom
.
hex
(
20
)
}
accepts_nested_attributes_for
:geo_node_key
accepts_nested_attributes_for
:geo_node_key
,
:system_hook
validates
:host
,
host:
true
,
presence:
true
,
uniqueness:
{
case_sensitive:
false
,
scope: :port
}
validates
:primary
,
uniqueness:
{
message:
'node already exists'
},
if: :primary
...
...
@@ -90,7 +90,7 @@ class GeoNode < ActiveRecord::Base
def
update_dependents_attributes
self
.
geo_node_key
.
title
=
"Geo node:
#{
self
.
url
}
"
if
self
.
geo_node_key
self
.
token
=
SecureRandom
.
hex
(
20
)
if
self
.
token
.
empty
?
self
.
token
=
SecureRandom
.
hex
(
20
)
if
!
self
.
token
.
present
?
if
self
.
primary?
self
.
oauth_application
=
nil
...
...
spec/models/geo_node_spec.rb
View file @
a9095fcc
...
...
@@ -56,15 +56,12 @@ describe GeoNode, type: :model do
let
(
:geo_node_key_attributes
)
{
FactoryGirl
.
build
(
:geo_node_key
).
attributes
}
context
'on initialize'
do
before
(
:each
)
do
new_node
.
geo_node_key_attributes
=
geo_node_key_attributes
end
it
'initializes a corresponding key'
do
expect
(
new_node
.
geo_node_key
).
to
be_present
end
it
'is valid'
do
it
'is valid when required attributes are present'
do
new_node
.
geo_node_key_attributes
=
geo_node_key_attributes
expect
(
new_node
).
to
be_valid
end
end
...
...
@@ -81,6 +78,17 @@ describe GeoNode, type: :model do
it
'has no oauth_application if it is a primary node'
do
expect
(
primary_node
.
oauth_application
).
not_to
be_present
end
it
'has a system_hook if it is a secondary node'
do
expect
(
node
.
system_hook
).
to
be_present
end
it
'generated system_hook has required attributes'
do
expect
(
node
.
system_hook
.
url
).
to
be_present
expect
(
node
.
system_hook
.
url
).
to
eq
(
node
.
geo_events_url
)
expect
(
node
.
system_hook
.
token
).
to
be_present
expect
(
node
.
system_hook
.
token
).
to
eq
(
node
.
token
)
end
end
end
...
...
@@ -163,11 +171,11 @@ describe GeoNode, type: :model do
end
end
describe
'#
notify_key
_url'
do
let
(
:
refresh_url
)
{
'https://localhost:3000/gitlab/api/v3/geo/refresh_key
'
}
describe
'#
geo_events
_url'
do
let
(
:
events_url
)
{
'https://localhost:3000/gitlab/api/v3/geo/receive_events
'
}
it
'returns api url based on node uri'
do
expect
(
new_node
.
notify_key_url
).
to
eq
(
refresh
_url
)
expect
(
new_node
.
geo_events_url
).
to
eq
(
events
_url
)
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