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
54108b6c
Commit
54108b6c
authored
Mar 21, 2016
by
Gabriel Mazetto
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added specs for Geo Key synchronization and fixed mistakes
parent
9ba1c009
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
68 additions
and
4 deletions
+68
-4
app/services/geo/schedule_key_change_service.rb
app/services/geo/schedule_key_change_service.rb
+1
-1
app/workers/geo_key_refresh_worker.rb
app/workers/geo_key_refresh_worker.rb
+2
-0
spec/requests/api/geo_spec.rb
spec/requests/api/geo_spec.rb
+22
-3
spec/services/geo/schedule_key_change_service_spec.rb
spec/services/geo/schedule_key_change_service_spec.rb
+20
-0
spec/workers/geo_key_refresh_worker_spec.rb
spec/workers/geo_key_refresh_worker_spec.rb
+23
-0
No files found.
app/services/geo/schedule_key_change_service.rb
View file @
54108b6c
...
...
@@ -8,7 +8,7 @@ module Geo
end
def
execute
GeoKeyRefreshWorker
.
perform_async
(
project
[
'id'
],
project
[
'clone_url'
]
)
GeoKeyRefreshWorker
.
perform_async
(
@id
,
@action
)
end
end
end
app/workers/geo_key_refresh_worker.rb
View file @
54108b6c
...
...
@@ -19,6 +19,8 @@ class GeoKeyRefreshWorker
# ActiveRecord::RecordNotFound when not found (so job will retry)
key
=
Key
.
find
(
key_id
)
key
.
remove_from_shell
else
fail
"Invalid action:
#{
action
}
"
end
end
...
...
spec/requests/api/geo_spec.rb
View file @
54108b6c
...
...
@@ -8,14 +8,33 @@ describe API::API, api: true do
describe
'POST /geo/refresh_projects'
do
before
(
:each
)
{
allow_any_instance_of
(
::
Geo
::
ScheduleRepoUpdateService
).
to
receive
(
:execute
)
}
it
's
hould retrieve the license information if admin is logged in
'
do
it
's
tarts refresh process if admin and correct params
'
do
post
api
(
'/geo/refresh_projects'
,
admin
),
projects:
[
'1'
,
'2'
,
'3'
]
expect
(
response
.
status
).
to
eq
201
end
it
'
should deny
access if not admin'
do
it
'
denies
access if not admin'
do
post
api
(
'/geo/refresh_projects'
,
user
)
expect
(
response
.
status
).
to
eq
403
end
end
describe
'POST /geo/refresh_key'
do
before
(
:each
)
{
allow_any_instance_of
(
::
Geo
::
ScheduleKeyChangeService
).
to
receive
(
:execute
)
}
it
'enqueues on disk key creation if admin and correct params'
do
post
api
(
'/geo/refresh_key'
,
admin
),
key_change:
{
id:
1
,
action:
'create'
}
expect
(
response
.
status
).
to
eq
201
end
it
'enqueues on disk key removal if admin and correct params'
do
post
api
(
'/geo/refresh_key'
,
admin
),
key_change:
{
id:
1
,
action:
'delete'
}
expect
(
response
.
status
).
to
eq
201
end
it
'denies access if not admin'
do
post
api
(
'/geo/refresh_key'
,
user
)
expect
(
response
.
status
).
to
eq
403
end
end
end
spec/services/geo/schedule_key_change_service_spec.rb
0 → 100644
View file @
54108b6c
require
'spec_helper'
describe
Geo
::
ScheduleKeyChangeService
,
service:
true
do
subject
(
:key_create
)
{
Geo
::
ScheduleKeyChangeService
.
new
({
'id'
=>
1
,
'action'
=>
'create'
})
}
subject
(
:key_delete
)
{
Geo
::
ScheduleKeyChangeService
.
new
({
'id'
=>
1
,
'action'
=>
'delete'
})
}
before
(
:each
)
{
allow_any_instance_of
(
GeoKeyRefreshWorker
).
to
receive
(
:perform
)
}
context
'key creation'
do
it
'executes action'
do
expect
(
key_create
.
execute
).
to
be_truthy
end
end
context
'key removal'
do
it
'executes action'
do
expect
(
key_delete
.
execute
).
to
be_truthy
end
end
end
spec/workers/geo_key_refresh_worker_spec.rb
0 → 100644
View file @
54108b6c
require
'spec_helper'
describe
GeoKeyRefreshWorker
do
subject
(
:key_create
)
{
described_class
.
new
.
perform
(
key
.
id
,
'create'
)
}
subject
(
:key_delete
)
{
described_class
.
new
.
perform
(
key
.
id
,
'delete'
)
}
let
(
:key
)
{
FactoryGirl
.
create
(
:key
)
}
context
'key creation'
do
it
'adds key to shell'
do
expect
(
Key
).
to
receive
(
:find
).
with
(
key
.
id
)
{
key
}
expect
(
key
).
to
receive
(
:add_to_shell
)
expect
{
key_create
}.
not_to
raise_error
end
end
context
'key removal'
do
it
'removes key from the shell'
do
expect
(
Key
).
to
receive
(
:find
).
with
(
key
.
id
)
{
key
}
expect
(
key
).
to
receive
(
:remove_from_shell
)
expect
{
key_delete
}.
not_to
raise_error
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