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
a89a5131
Commit
a89a5131
authored
Aug 02, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Delegates the update of the Geo node to Geo::NodeUpdateService
parent
4007551e
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
40 additions
and
3 deletions
+40
-3
app/models/geo_node.rb
app/models/geo_node.rb
+4
-0
app/services/geo/node_update_service.rb
app/services/geo/node_update_service.rb
+27
-0
ee/app/controllers/admin/geo_nodes_controller.rb
ee/app/controllers/admin/geo_nodes_controller.rb
+1
-1
spec/controllers/admin/geo_nodes_controller_spec.rb
spec/controllers/admin/geo_nodes_controller_spec.rb
+8
-2
No files found.
app/models/geo_node.rb
View file @
a89a5131
...
...
@@ -108,6 +108,10 @@ class GeoNode < ActiveRecord::Base
end
end
def
namespaces_changed?
namespaces
.
any?
{
|
n
|
n
.
new_record?
||
n
.
marked_for_destruction?
}
end
def
project_ids
return
unless
namespaces
.
presence
...
...
app/services/geo/node_update_service.rb
0 → 100644
View file @
a89a5131
module
Geo
class
NodeUpdateService
attr_reader
:geo_node
,
:old_namespace_ids
,
:params
def
initialize
(
geo_node
,
params
)
@geo_node
=
geo_node
@old_namespace_ids
=
geo_node
.
namespace_ids
@params
=
params
.
except
(
:geo_node_key_attributes
)
end
def
execute
return
false
unless
geo_node
.
update
(
params
)
if
namespaces_changed?
(
geo_node
)
Geo
::
RepositoriesChangedEventStore
.
new
(
geo_node
).
create
end
geo_node
end
private
def
namespaces_changed?
(
geo_node
)
geo_node
.
namespace_ids
.
any?
&&
geo_node
.
namespace_ids
!=
old_namespace_ids
end
end
end
ee/app/controllers/admin/geo_nodes_controller.rb
View file @
a89a5131
...
...
@@ -25,7 +25,7 @@ class Admin::GeoNodesController < Admin::ApplicationController
end
def
update
if
@node
.
update_attributes
(
geo_node_params
.
except
(
:geo_node_key_attributes
))
if
Geo
::
NodeUpdateService
.
new
(
@node
,
geo_node_params
).
execute
redirect_to
admin_geo_nodes_path
,
notice:
'Geo Node was successfully updated.'
else
render
'edit'
...
...
spec/controllers/admin/geo_nodes_controller_spec.rb
View file @
a89a5131
...
...
@@ -132,15 +132,21 @@ describe Admin::GeoNodesController, :postgresql do
context
'with add-on license'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:license_allows?
).
and_return
(
true
)
go
end
it
'updates the node without changing the key'
do
g
eo_node
.
reload
g
o
geo_node
.
reload
expect
(
geo_node
.
url
.
chomp
(
'/'
)).
to
eq
(
geo_node_attributes
[
:url
])
expect
(
geo_node
.
geo_node_key
.
fingerprint
).
to
eq
(
original_fingerprint
)
end
it
'delegates the update of the Geo node to Geo::NodeUpdateService'
do
expect_any_instance_of
(
Geo
::
NodeUpdateService
).
to
receive
(
:execute
).
once
go
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