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 ...@@ -140,6 +140,13 @@ module ErrorTracking
Addressable::URI.join(api_url, '/').to_s Addressable::URI.join(api_url, '/').to_s
end 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 private
def add_gitlab_issue_details(issue) def add_gitlab_issue_details(issue)
......
...@@ -9,6 +9,7 @@ module ErrorTracking ...@@ -9,6 +9,7 @@ module ErrorTracking
unless parse_errors(response).present? unless parse_errors(response).present?
response[:closed_issue_iid] = update_related_issue&.iid response[:closed_issue_iid] = update_related_issue&.iid
clear_cache
end end
response response
...@@ -28,6 +29,10 @@ module ErrorTracking ...@@ -28,6 +29,10 @@ module ErrorTracking
close_and_create_note(issue) close_and_create_note(issue)
end end
def clear_cache
project_error_tracking_setting.clear_cache('list_issues')
end
def close_and_create_note(issue) def close_and_create_note(issue)
return unless resolving? && issue.opened? return unless resolving? && issue.opened?
......
...@@ -440,4 +440,18 @@ describe ErrorTracking::ProjectErrorTrackingSetting do ...@@ -440,4 +440,18 @@ describe ErrorTracking::ProjectErrorTrackingSetting do
end end
end 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 end
...@@ -40,6 +40,14 @@ describe ErrorTracking::IssueUpdateService do ...@@ -40,6 +40,14 @@ describe ErrorTracking::IssueUpdateService do
result result
end 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 context 'related issue and resolving' do
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:sentry_issue) { create(:sentry_issue, issue: issue) } 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