Commit 156baa54 authored by Sean Arnold's avatar Sean Arnold Committed by Douglas Barbosa Alexandre

Clear list issue cache after issue update

- add clear_cache method to error tracking setting
parent 1ec39914
......@@ -140,6 +140,13 @@ module ErrorTracking
Addressable::URI.join(api_url, '/').to_s
end
def clear_cache(key_prefix)
return unless key_prefix
klass_key = self.class.reactive_cache_key.call(self).join(':')
Rails.cache.delete_matched("#{klass_key}:#{key_prefix}*")
end
private
def add_gitlab_issue_details(issue)
......
......@@ -9,6 +9,7 @@ module ErrorTracking
unless parse_errors(response).present?
response[:closed_issue_iid] = update_related_issue&.iid
clear_cache
end
response
......@@ -28,6 +29,10 @@ module ErrorTracking
close_and_create_note(issue)
end
def clear_cache
project_error_tracking_setting.clear_cache('list_issues')
end
def close_and_create_note(issue)
return unless resolving? && issue.opened?
......
......@@ -440,4 +440,18 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end
end
end
describe '#clear_cache' do
let(:key_prefix) { 'list_issues' }
it 'clears the cache' do
klass_key = subject.class.reactive_cache_key.call(subject).join(':')
expect(Rails.cache)
.to receive(:delete_matched)
.with("#{klass_key}:#{key_prefix}*")
subject.clear_cache(key_prefix)
end
end
end
......@@ -40,6 +40,14 @@ describe ErrorTracking::IssueUpdateService do
result
end
it 'clears the reactive cache' do
expect(error_tracking_setting)
.to receive(:clear_cache)
.with('list_issues')
result
end
context 'related issue and resolving' do
let(:issue) { create(:issue, project: project) }
let(:sentry_issue) { create(:sentry_issue, issue: issue) }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment