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
)
def
execute
(
token
)
client
=
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token
,
nil
)
client
=
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token
,
nil
)
# Lists only projects with billing enabled
client
.
projects_list
.
select
do
|
project
|
client
.
projects_list
.
select
do
|
project
|
begin
begin
client
.
projects_get_billing_info
(
project
.
project_id
).
billing_enabled
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
...
@@ -37,7 +37,7 @@ class CheckGcpProjectBillingWorker
return
unless
token
return
unless
token
return
unless
try_obtain_lease_for
(
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
)
update_billing_change_counter
(
self
.
class
.
get_billing_state
(
token
),
billing_enabled_state
)
self
.
class
.
set_billing_state
(
token
,
billing_enabled_state
)
self
.
class
.
set_billing_state
(
token
,
billing_enabled_state
)
end
end
...
...
spec/services/
check_gcp_project_billing
_service_spec.rb
→
spec/services/
list_gcp_projects
_service_spec.rb
View file @
cffc8899
require
'spec_helper'
require
'spec_helper'
describe
CheckGcpProjectBilling
Service
do
describe
ListGcpProjects
Service
do
include
GoogleApi
::
CloudPlatformHelpers
include
GoogleApi
::
CloudPlatformHelpers
let
(
:service
)
{
described_class
.
new
}
let
(
:service
)
{
described_class
.
new
}
...
...
spec/workers/check_gcp_project_billing_worker_spec.rb
View file @
cffc8899
...
@@ -22,13 +22,13 @@ describe CheckGcpProjectBillingWorker do
...
@@ -22,13 +22,13 @@ describe CheckGcpProjectBillingWorker do
end
end
it
'calls the service'
do
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
subject
end
end
it
'stores billing status in redis'
do
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
)
expect
(
described_class
).
to
receive
(
:set_billing_state
).
with
(
token
,
true
)
subject
subject
...
@@ -41,7 +41,7 @@ describe CheckGcpProjectBillingWorker do
...
@@ -41,7 +41,7 @@ describe CheckGcpProjectBillingWorker do
end
end
it
'does not call the service'
do
it
'does not call the service'
do
expect
(
CheckGcpProjectBilling
Service
).
not_to
receive
(
:new
)
expect
(
ListGcpProjects
Service
).
not_to
receive
(
:new
)
subject
subject
end
end
...
@@ -54,7 +54,7 @@ describe CheckGcpProjectBillingWorker do
...
@@ -54,7 +54,7 @@ describe CheckGcpProjectBillingWorker do
end
end
it
'does not call the service'
do
it
'does not call the service'
do
expect
(
CheckGcpProjectBilling
Service
).
not_to
receive
(
:new
)
expect
(
ListGcpProjects
Service
).
not_to
receive
(
:new
)
subject
subject
end
end
...
@@ -77,7 +77,7 @@ describe CheckGcpProjectBillingWorker do
...
@@ -77,7 +77,7 @@ describe CheckGcpProjectBillingWorker do
context
'when the current state is false'
do
context
'when the current state is false'
do
before
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
end
it
'increments the billing change counter'
do
it
'increments the billing change counter'
do
...
@@ -89,7 +89,7 @@ describe CheckGcpProjectBillingWorker do
...
@@ -89,7 +89,7 @@ describe CheckGcpProjectBillingWorker do
context
'when the current state is true'
do
context
'when the current state is true'
do
before
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
end
it
'increments the billing change counter'
do
it
'increments the billing change counter'
do
...
@@ -103,7 +103,7 @@ describe CheckGcpProjectBillingWorker do
...
@@ -103,7 +103,7 @@ describe CheckGcpProjectBillingWorker do
context
'when previous state was true'
do
context
'when previous state was true'
do
before
do
before
do
expect
(
described_class
).
to
receive
(
:get_billing_state
).
and_return
(
true
)
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
end
it
'increment the billing change counter'
do
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