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
3e208129
Commit
3e208129
authored
Aug 02, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add missing specs for Geo::NodeUpdateService
parent
a89a5131
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
1 deletion
+49
-1
app/services/geo/node_update_service.rb
app/services/geo/node_update_service.rb
+1
-1
spec/services/geo/node_update_service_spec.rb
spec/services/geo/node_update_service_spec.rb
+48
-0
No files found.
app/services/geo/node_update_service.rb
View file @
3e208129
...
...
@@ -11,7 +11,7 @@ module Geo
def
execute
return
false
unless
geo_node
.
update
(
params
)
if
namespaces_changed?
(
geo_node
)
if
geo_node
.
secondary?
&&
namespaces_changed?
(
geo_node
)
Geo
::
RepositoriesChangedEventStore
.
new
(
geo_node
).
create
end
...
...
spec/services/geo/node_update_service_spec.rb
0 → 100644
View file @
3e208129
require
'spec_helper'
describe
Geo
::
NodeUpdateService
do
let
(
:group
)
{
create
(
:group
)
}
let!
(
:primary
)
{
create
(
:geo_node
,
:primary
,
:current
)
}
let
(
:geo_node
)
{
create
(
:geo_node
)
}
let
(
:geo_node_with_restrictions
)
{
create
(
:geo_node
,
namespace_ids:
[
group
.
id
])
}
describe
'#execute'
do
it
'updates the node without changing the key'
do
original_fingerprint
=
geo_node
.
geo_node_key
.
fingerprint
params
=
{
url:
'http://example.com'
,
geo_node_key_attributes:
attributes_for
(
:key
)
}
service
=
described_class
.
new
(
geo_node
,
params
)
service
.
execute
geo_node
.
reload
expect
(
geo_node
.
url
.
chomp
(
'/'
)).
to
eq
(
params
[
:url
])
expect
(
geo_node
.
geo_node_key
.
fingerprint
).
to
eq
(
original_fingerprint
)
end
it
'returns false when update fails'
do
allow
(
geo_node
).
to
receive
(
:update
).
and_return
(
false
)
service
=
described_class
.
new
(
geo_node
,
{
url:
'http://example.com'
})
expect
(
service
.
execute
).
to
eq
false
end
it
'logs an event to the Geo event log when namespaces change'
do
service
=
described_class
.
new
(
geo_node
,
namespace_ids:
[
group
.
id
])
expect
{
service
.
execute
}.
to
change
(
Geo
::
RepositoriesChangedEvent
,
:count
).
by
(
1
)
end
it
'does not log an event to the Geo event log when removing namespace restrictions'
do
service
=
described_class
.
new
(
geo_node_with_restrictions
,
namespace_ids:
[])
expect
{
service
.
execute
}.
not_to
change
(
Geo
::
RepositoriesChangedEvent
,
:count
)
end
it
'does not log an event to the Geo event log when node is a primary node'
do
service
=
described_class
.
new
(
primary
,
namespace_ids:
[
group
.
id
])
expect
{
service
.
execute
}.
not_to
change
(
Geo
::
RepositoriesChangedEvent
,
:count
)
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