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
0
Merge Requests
0
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
Boxiang Sun
gitlab-ce
Commits
cffc8899
Commit
cffc8899
authored
Apr 20, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename CheckGcpProjectBillingService to ListGcpProjectsService
parent
d1052289
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
11 additions
and
10 deletions
+11
-10
app/services/list_gcp_projects_service.rb
app/services/list_gcp_projects_service.rb
+2
-1
app/workers/check_gcp_project_billing_worker.rb
app/workers/check_gcp_project_billing_worker.rb
+1
-1
spec/services/list_gcp_projects_service_spec.rb
spec/services/list_gcp_projects_service_spec.rb
+1
-1
spec/workers/check_gcp_project_billing_worker_spec.rb
spec/workers/check_gcp_project_billing_worker_spec.rb
+7
-7
No files found.
app/services/
check_gcp_project_billing
_service.rb
→
app/services/
list_gcp_projects
_service.rb
View file @
cffc8899
class
CheckGcpProjectBilling
Service
class
ListGcpProjects
Service
def
execute
(
token
)
client
=
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token
,
nil
)
# Lists only projects with billing enabled
client
.
projects_list
.
select
do
|
project
|
begin
client
.
projects_get_billing_info
(
project
.
project_id
).
billing_enabled
...
...
app/workers/check_gcp_project_billing_worker.rb
View file @
cffc8899
...
...
@@ -37,7 +37,7 @@ class CheckGcpProjectBillingWorker
return
unless
token
return
unless
try_obtain_lease_for
(
token
)
billing_enabled_state
=
!
CheckGcpProjectBilling
Service
.
new
.
execute
(
token
).
empty?
billing_enabled_state
=
!
ListGcpProjects
Service
.
new
.
execute
(
token
).
empty?
update_billing_change_counter
(
self
.
class
.
get_billing_state
(
token
),
billing_enabled_state
)
self
.
class
.
set_billing_state
(
token
,
billing_enabled_state
)
end
...
...
spec/services/
check_gcp_project_billing
_service_spec.rb
→
spec/services/
list_gcp_projects
_service_spec.rb
View file @
cffc8899
require
'spec_helper'
describe
CheckGcpProjectBilling
Service
do
describe
ListGcpProjects
Service
do
include
GoogleApi
::
CloudPlatformHelpers
let
(
:service
)
{
described_class
.
new
}
...
...
spec/workers/check_gcp_project_billing_worker_spec.rb
View file @
cffc8899
...
...
@@ -22,13 +22,13 @@ describe CheckGcpProjectBillingWorker do
end
it
'calls the service'
do
expect
(
CheckGcpProjectBilling
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
expect
(
ListGcpProjects
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
subject
end
it
'stores billing status in redis'
do
expect
(
CheckGcpProjectBilling
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
expect
(
ListGcpProjects
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
expect
(
described_class
).
to
receive
(
:set_billing_state
).
with
(
token
,
true
)
subject
...
...
@@ -41,7 +41,7 @@ describe CheckGcpProjectBillingWorker do
end
it
'does not call the service'
do
expect
(
CheckGcpProjectBilling
Service
).
not_to
receive
(
:new
)
expect
(
ListGcpProjects
Service
).
not_to
receive
(
:new
)
subject
end
...
...
@@ -54,7 +54,7 @@ describe CheckGcpProjectBillingWorker do
end
it
'does not call the service'
do
expect
(
CheckGcpProjectBilling
Service
).
not_to
receive
(
:new
)
expect
(
ListGcpProjects
Service
).
not_to
receive
(
:new
)
subject
end
...
...
@@ -77,7 +77,7 @@ describe CheckGcpProjectBillingWorker do
context
'when the current state is false'
do
before
do
expect
(
CheckGcpProjectBilling
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([])
expect
(
ListGcpProjects
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([])
end
it
'increments the billing change counter'
do
...
...
@@ -89,7 +89,7 @@ describe CheckGcpProjectBillingWorker do
context
'when the current state is true'
do
before
do
expect
(
CheckGcpProjectBilling
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
expect
(
ListGcpProjects
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
end
it
'increments the billing change counter'
do
...
...
@@ -103,7 +103,7 @@ describe CheckGcpProjectBillingWorker do
context
'when previous state was true'
do
before
do
expect
(
described_class
).
to
receive
(
:get_billing_state
).
and_return
(
true
)
expect
(
CheckGcpProjectBilling
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
expect
(
ListGcpProjects
Service
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
end
it
'increment the billing change counter'
do
...
...
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