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
7f430a91
Commit
7f430a91
authored
Feb 06, 2018
by
Matija Čupić
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add specs for billing_enabled change counter
parent
0dd20200
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
66 additions
and
0 deletions
+66
-0
spec/workers/check_gcp_project_billing_worker_spec.rb
spec/workers/check_gcp_project_billing_worker_spec.rb
+66
-0
No files found.
spec/workers/check_gcp_project_billing_worker_spec.rb
View file @
7f430a91
...
...
@@ -6,6 +6,11 @@ describe CheckGcpProjectBillingWorker do
subject
{
described_class
.
new
.
perform
(
'token_key'
)
}
before
do
allow_any_instance_of
(
described_class
).
to
receive
(
:check_previous_state
)
allow_any_instance_of
(
described_class
).
to
receive
(
:update_billing_change_counter
)
end
context
'when there is a token in redis'
do
before
do
allow
(
described_class
).
to
receive
(
:get_session_token
).
and_return
(
token
)
...
...
@@ -58,4 +63,65 @@ describe CheckGcpProjectBillingWorker do
end
end
end
describe
'billing change counter'
do
subject
{
described_class
.
new
.
perform
(
'token_key'
)
}
before
do
allow
(
described_class
).
to
receive
(
:get_session_token
).
and_return
(
'bogustoken'
)
allow_any_instance_of
(
described_class
).
to
receive
(
:try_obtain_lease_for
).
and_return
(
'randomuuid'
)
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
allow
(
redis
).
to
receive
(
:set
)
end
end
context
'when previous state was false'
do
before
do
expect_any_instance_of
(
described_class
).
to
receive
(
:check_previous_state
).
and_return
(
'false'
)
end
context
'when the current state is false'
do
before
do
expect
(
CheckGcpProjectBillingService
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([])
end
it
'does not increment the billing change counter'
do
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
expect
(
redis
).
not_to
receive
(
:incr
)
end
subject
end
end
context
'when the current state is true'
do
before
do
expect
(
CheckGcpProjectBillingService
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
end
it
'increments the billing change counter'
do
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
expect
(
redis
).
to
receive
(
:incr
)
end
subject
end
end
end
context
'when previous state was true'
do
before
do
expect_any_instance_of
(
described_class
).
to
receive
(
:check_previous_state
).
and_return
(
'true'
)
expect
(
CheckGcpProjectBillingService
).
to
receive_message_chain
(
:new
,
:execute
).
and_return
([
double
])
end
it
'does not increment the billing change counter'
do
Gitlab
::
Redis
::
SharedState
.
with
do
|
redis
|
expect
(
redis
).
not_to
receive
(
:incr
)
end
subject
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