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
3eca6c3a
Commit
3eca6c3a
authored
Mar 07, 2017
by
Douglas Barbosa Alexandre
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Check if node was successfully enabled or disabled
parent
ee36ef1d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
43 additions
and
12 deletions
+43
-12
app/controllers/admin/geo_nodes_controller.rb
app/controllers/admin/geo_nodes_controller.rb
+7
-4
spec/controllers/admin/geo_nodes_controller_spec.rb
spec/controllers/admin/geo_nodes_controller_spec.rb
+36
-8
No files found.
app/controllers/admin/geo_nodes_controller.rb
View file @
3eca6c3a
...
...
@@ -44,10 +44,13 @@ class Admin::GeoNodesController < Admin::ApplicationController
if
@node
.
primary?
flash
[
:alert
]
=
"Primary node can't be disabled."
else
@node
.
toggle!
(
:enabled
)
new_status
=
@node
.
enabled?
?
'enabled'
:
'disabled'
flash
[
:notice
]
=
"Node
#{
@node
.
url
}
was successfully
#{
new_status
}
."
if
@node
.
toggle!
(
:enabled
)
new_status
=
@node
.
enabled?
?
'enabled'
:
'disabled'
flash
[
:notice
]
=
"Node
#{
@node
.
url
}
was successfully
#{
new_status
}
."
else
action
=
@node
.
enabled?
?
'disabling'
:
'enabling'
flash
[
:alert
]
=
"There was a problem
#{
action
}
node
#{
@node
.
url
}
."
end
end
redirect_to
admin_geo_nodes_path
...
...
spec/controllers/admin/geo_nodes_controller_spec.rb
View file @
3eca6c3a
...
...
@@ -131,10 +131,13 @@ describe Admin::GeoNodesController do
context
'with add-on license'
do
before
do
allow
(
Gitlab
::
Geo
).
to
receive
(
:license_allows?
).
and_return
(
true
)
post
:toggle
,
id:
geo_node
end
context
'with a primary node'
do
before
do
post
:toggle
,
id:
geo_node
end
let
(
:geo_node
)
{
create
(
:geo_node
,
:primary
,
enabled:
true
)
}
it
'does not disable the node'
do
...
...
@@ -153,16 +156,41 @@ describe Admin::GeoNodesController do
context
'with a secondary node'
do
let
(
:geo_node
)
{
create
(
:geo_node
,
host:
'example.com'
,
port:
80
,
enabled:
true
)
}
it
'disables the node'
do
expect
(
geo_node
.
reload
).
not_to
be_enabled
end
context
'when succeed'
do
before
do
post
:toggle
,
id:
geo_node
end
it
'displays a flash message'
do
expect
(
controller
).
to
set_flash
.
now
[
:notice
].
to
(
'Node http://example.com/ was successfully disabled.'
)
it
'disables the node'
do
expect
(
geo_node
.
reload
).
not_to
be_enabled
end
it
'displays a flash message'
do
expect
(
controller
).
to
set_flash
.
now
[
:notice
].
to
(
'Node http://example.com/ was successfully disabled.'
)
end
it
'redirects to the geo nodes page'
do
expect
(
response
).
to
redirect_to
(
admin_geo_nodes_path
)
end
end
it
'redirects to the geo nodes page'
do
expect
(
response
).
to
redirect_to
(
admin_geo_nodes_path
)
context
'when fail'
do
before
do
allow_any_instance_of
(
GeoNode
).
to
receive
(
:toggle!
).
and_return
(
false
)
post
:toggle
,
id:
geo_node
end
it
'does not disable the node'
do
expect
(
geo_node
.
reload
).
to
be_enabled
end
it
'displays a flash message'
do
expect
(
controller
).
to
set_flash
.
now
[
:alert
].
to
(
'There was a problem disabling node http://example.com/.'
)
end
it
'redirects to the geo nodes page'
do
expect
(
response
).
to
redirect_to
(
admin_geo_nodes_path
)
end
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