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
79a30c82
Commit
79a30c82
authored
Mar 30, 2021
by
Vijay Hawoldar
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change future renewal service cache key
To ensure the cache is expired when the subscription is updated
parent
671982d6
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
19 additions
and
12 deletions
+19
-12
ee/app/services/gitlab_subscriptions/check_future_renewal_service.rb
...ices/gitlab_subscriptions/check_future_renewal_service.rb
+5
-5
ee/lib/ee/api/namespaces.rb
ee/lib/ee/api/namespaces.rb
+1
-0
ee/lib/gitlab/expiring_subscription_message.rb
ee/lib/gitlab/expiring_subscription_message.rb
+1
-1
ee/spec/lib/gitlab/expiring_subscription_message_spec.rb
ee/spec/lib/gitlab/expiring_subscription_message_spec.rb
+2
-2
ee/spec/requests/api/namespaces_spec.rb
ee/spec/requests/api/namespaces_spec.rb
+6
-0
ee/spec/services/gitlab_subscriptions/check_future_renewal_service_spec.rb
...gitlab_subscriptions/check_future_renewal_service_spec.rb
+4
-4
No files found.
ee/app/services/gitlab_subscriptions/check_future_renewal_service.rb
View file @
79a30c82
...
@@ -9,8 +9,8 @@
...
@@ -9,8 +9,8 @@
# returns true, false
# returns true, false
module
GitlabSubscriptions
module
GitlabSubscriptions
class
CheckFutureRenewalService
class
CheckFutureRenewalService
def
initialize
(
namespace
_id
:)
def
initialize
(
namespace
:)
@namespace
_id
=
namespace_id
@namespace
=
namespace
end
end
def
execute
def
execute
...
@@ -21,14 +21,14 @@ module GitlabSubscriptions
...
@@ -21,14 +21,14 @@ module GitlabSubscriptions
private
private
attr_reader
:namespace
_id
attr_reader
:namespace
def
client
def
client
Gitlab
::
SubscriptionPortal
::
Client
Gitlab
::
SubscriptionPortal
::
Client
end
end
def
last_term_request
def
last_term_request
response
=
client
.
subscription_last_term
(
namespace
_
id
)
response
=
client
.
subscription_last_term
(
namespace
.
id
)
if
response
[
:success
]
if
response
[
:success
]
response
[
:last_term
]
==
false
response
[
:last_term
]
==
false
...
@@ -42,7 +42,7 @@ module GitlabSubscriptions
...
@@ -42,7 +42,7 @@ module GitlabSubscriptions
end
end
def
cache_key
def
cache_key
"subscription:future_renewal:namespace:
#{
namespace
_id
}
"
"subscription:future_renewal:namespace:
#{
namespace
.
gitlab_subscription
.
cache_key
}
"
end
end
def
future_renewal
def
future_renewal
...
...
ee/lib/ee/api/namespaces.rb
View file @
79a30c82
...
@@ -123,6 +123,7 @@ module EE
...
@@ -123,6 +123,7 @@ module EE
subscription_params
=
declared_params
(
include_missing:
false
)
subscription_params
=
declared_params
(
include_missing:
false
)
subscription_params
[
:trial_starts_on
]
||=
subscription_params
[
:start_date
]
if
subscription_params
[
:trial
]
subscription_params
[
:trial_starts_on
]
||=
subscription_params
[
:start_date
]
if
subscription_params
[
:trial
]
subscription_params
[
:updated_at
]
=
Time
.
current
if
subscription
.
update
(
subscription_params
)
if
subscription
.
update
(
subscription_params
)
present
subscription
,
with:
::
EE
::
API
::
Entities
::
GitlabSubscription
present
subscription
,
with:
::
EE
::
API
::
Entities
::
GitlabSubscription
...
...
ee/lib/gitlab/expiring_subscription_message.rb
View file @
79a30c82
...
@@ -122,7 +122,7 @@ module Gitlab
...
@@ -122,7 +122,7 @@ module Gitlab
def
subscription_future_renewal?
def
subscription_future_renewal?
return
if
self_managed?
||
namespace
.
nil?
return
if
self_managed?
||
namespace
.
nil?
::
GitlabSubscriptions
::
CheckFutureRenewalService
.
new
(
namespace
_id:
namespace
.
id
).
execute
::
GitlabSubscriptions
::
CheckFutureRenewalService
.
new
(
namespace
:
namespace
).
execute
end
end
def
require_notification?
def
require_notification?
...
...
ee/spec/lib/gitlab/expiring_subscription_message_spec.rb
View file @
79a30c82
...
@@ -115,7 +115,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
...
@@ -115,7 +115,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
let_it_be
(
:namespace
)
{
create
(
:group
,
name:
'No Limit Records'
)
}
let_it_be
(
:namespace
)
{
create
(
:group
,
name:
'No Limit Records'
)
}
before
do
before
do
allow_next_instance_of
(
GitlabSubscriptions
::
CheckFutureRenewalService
,
namespace
_id:
namespace
.
id
)
do
|
service
|
allow_next_instance_of
(
GitlabSubscriptions
::
CheckFutureRenewalService
,
namespace
:
namespace
)
do
|
service
|
allow
(
service
).
to
receive
(
:execute
).
and_return
(
has_future_renewal
)
allow
(
service
).
to
receive
(
:execute
).
and_return
(
has_future_renewal
)
end
end
end
end
...
@@ -203,7 +203,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
...
@@ -203,7 +203,7 @@ RSpec.describe Gitlab::ExpiringSubscriptionMessage do
let_it_be
(
:namespace
)
{
create
(
:group
,
name:
'No Limit Records'
)
}
let_it_be
(
:namespace
)
{
create
(
:group
,
name:
'No Limit Records'
)
}
before
do
before
do
allow_next_instance_of
(
GitlabSubscriptions
::
CheckFutureRenewalService
,
namespace
_id:
namespace
.
id
)
do
|
service
|
allow_next_instance_of
(
GitlabSubscriptions
::
CheckFutureRenewalService
,
namespace
:
namespace
)
do
|
service
|
allow
(
service
).
to
receive
(
:execute
).
and_return
(
has_future_renewal
)
allow
(
service
).
to
receive
(
:execute
).
and_return
(
has_future_renewal
)
end
end
end
end
...
...
ee/spec/requests/api/namespaces_spec.rb
View file @
79a30c82
...
@@ -532,6 +532,12 @@ RSpec.describe API::Namespaces do
...
@@ -532,6 +532,12 @@ RSpec.describe API::Namespaces do
max_seats_used:
42
max_seats_used:
42
)
)
end
end
it
'updates the timestamp when the attributes are the same'
do
expect
do
do_put
(
namespace
.
id
,
admin
,
gitlab_subscription
.
attributes
)
end
.
to
change
{
gitlab_subscription
.
reload
.
updated_at
}
end
end
end
end
end
...
...
ee/spec/services/gitlab_subscriptions/check_future_renewal_service_spec.rb
View file @
79a30c82
...
@@ -6,11 +6,11 @@ RSpec.describe GitlabSubscriptions::CheckFutureRenewalService, :use_clean_rails_
...
@@ -6,11 +6,11 @@ RSpec.describe GitlabSubscriptions::CheckFutureRenewalService, :use_clean_rails_
using
RSpec
::
Parameterized
::
TableSyntax
using
RSpec
::
Parameterized
::
TableSyntax
describe
'#execute'
do
describe
'#execute'
do
let
(
:namespace
)
{
create
(
:namespace
)
}
let_it_be
(
:namespace
)
{
create
(
:namespace_with_plan
)
}
let
(
:namespace_id
)
{
namespace
.
id
}
let
(
:cache_key
)
{
"subscription:future_renewal:namespace:
#{
namespace_id
}
"
}
subject
(
:execute_service
)
{
described_class
.
new
(
namespace_id:
namespace_id
).
execute
}
let
(
:cache_key
)
{
"subscription:future_renewal:namespace:
#{
namespace
.
gitlab_subscription
.
cache_key
}
"
}
subject
(
:execute_service
)
{
described_class
.
new
(
namespace:
namespace
).
execute
}
where
(
:in_last_term
,
:expected_response
)
do
where
(
:in_last_term
,
:expected_response
)
do
true
|
false
true
|
false
...
...
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