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
87f01506
Commit
87f01506
authored
Dec 16, 2017
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CheckGCPProjectBillingService
parent
84d8ca11
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
38 additions
and
0 deletions
+38
-0
app/services/check_gcp_project_billing_service.rb
app/services/check_gcp_project_billing_service.rb
+8
-0
spec/services/check_gcp_project_billing_service_spec.rb
spec/services/check_gcp_project_billing_service_spec.rb
+30
-0
No files found.
app/services/check_gcp_project_billing_service.rb
0 → 100644
View file @
87f01506
class
CheckGCPProjectBillingService
def
execute
(
token
)
client
=
GoogleApi
::
CloudPlatform
::
Client
.
new
(
token
,
nil
)
client
.
projects_list
.
any?
do
|
project
|
client
.
projects_get_billing_info
(
project
.
name
).
billingEnabled
end
end
end
spec/services/check_gcp_project_billing_service_spec.rb
0 → 100644
View file @
87f01506
require
'spec_helper'
describe
CheckGCPProjectBillingService
do
let
(
:service
)
{
described_class
.
new
}
describe
'#execute'
do
before
do
expect_any_instance_of
(
GoogleApi
::
CloudPlatform
::
Client
)
.
to
receive
(
:projects_list
).
and_return
([
double
(
name:
'project_name'
)])
expect_any_instance_of
(
GoogleApi
::
CloudPlatform
::
Client
)
.
to
receive_message_chain
(
:projects_get_billing_info
,
:billingEnabled
)
.
and_return
(
project_billing_enabled
)
end
subject
{
service
.
execute
(
'bogustoken'
)
}
context
'google account has a billing enabled gcp project'
do
let
(
:project_billing_enabled
)
{
true
}
it
{
is_expected
.
to
eq
(
true
)
}
end
context
'google account does not have a billing enabled gcp project'
do
let
(
:project_billing_enabled
)
{
false
}
it
{
is_expected
.
to
eq
(
false
)
}
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