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
a87f7983
Commit
a87f7983
authored
Jan 22, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs for Gitlab::Geo
parent
f90650dd
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
81 additions
and
0 deletions
+81
-0
spec/factories.rb
spec/factories.rb
+10
-0
spec/lib/gitlab/geo_spec.rb
spec/lib/gitlab/geo_spec.rb
+71
-0
No files found.
spec/factories.rb
View file @
a87f7983
...
...
@@ -244,4 +244,14 @@ FactoryGirl.define do
factory
:license
do
data
{
build
(
:gitlab_license
).
export
}
end
factory
:geo_node
do
host
{
Gitlab
.
config
.
gitlab
.
host
}
sequence
(
:port
)
{
|
n
|
n
}
trait
:primary
do
primary
true
port
{
Gitlab
.
config
.
gitlab
.
port
}
end
end
end
spec/lib/gitlab/geo_spec.rb
0 → 100644
View file @
a87f7983
require
'spec_helper'
describe
Gitlab
::
Geo
,
lib:
true
do
let
(
:primary_node
)
{
FactoryGirl
.
create
(
:geo_node
,
:primary
)
}
let
(
:secondary_node
)
{
FactoryGirl
.
create
(
:geo_node
)
}
describe
'current_node'
do
before
(
:each
)
{
primary_node
}
it
'returns a GeoNode instance'
do
expect
(
described_class
.
current_node
).
to
eq
(
primary_node
)
end
end
describe
'primary_node'
do
before
(
:each
)
do
primary_node
secondary_node
end
it
'returns a GeoNode primary instance'
do
expect
(
described_class
.
current_node
).
to
eq
(
primary_node
)
end
end
describe
'enabled?'
do
context
'when any GeoNode exists'
do
before
(
:each
)
{
secondary_node
}
it
'returns true'
do
expect
(
described_class
.
enabled?
).
to
be_truthy
end
end
context
'when no GeoNode exists'
do
it
'returns false'
do
expect
(
described_class
.
enabled?
).
to
be_falsey
end
end
end
describe
'readonly?'
do
context
'when current node is secondary'
do
before
(
:each
)
{
secondary_node
}
it
'returns true'
do
expect
(
described_class
).
to
receive
(
:current_node
)
{
secondary_node
}
expect
(
described_class
.
readonly?
).
to
be_truthy
end
end
context
'current node is primary'
do
before
(
:each
)
{
primary_node
}
it
'returns false when '
do
expect
(
described_class
).
to
receive
(
:current_node
)
{
primary_node
}
expect
(
described_class
.
readonly?
).
to
be_falsey
end
end
end
describe
'geo_node?'
do
it
'returns true if a node with specific host and port exists'
do
expect
(
described_class
.
geo_node?
(
host:
primary_node
.
host
,
port:
primary_node
.
port
)).
to
be_truthy
end
it
'returns false if specified host and port doesnt match any existing node'
do
expect
(
described_class
.
geo_node?
(
host:
'inexistent'
,
port:
1234
)).
to
be_falsey
end
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