Skip to content

Commit 743bdaf

Browse files
author
scardoso
committed
Fix testing errors
Fix problem caching Grape::Entity - This ensures Marshall.dump does not have issues with the Grape::Entity object we are caching via Rails.cache Reference: ruby-grape/grape-entity#299 Fix missing params for OccurenceCache init Include force flag in #fetch params Make sure hash has indifferent access
1 parent 68b2c77 commit 743bdaf

File tree

3 files changed

+6
-2
lines changed

3 files changed

+6
-2
lines changed

ee/app/serializers/vulnerabilities/occurrence_entity.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,4 +42,8 @@ class Vulnerabilities::OccurrenceEntity < Grape::Entity
4242
def current_user
4343
return request.current_user if request.respond_to?(:current_user)
4444
end
45+
46+
def as_json(*args)
47+
serializable_hash(*args).as_json.with_indifferent_access
48+
end
4549
end

ee/lib/gitlab/vulnerabilities/occurence.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def vulnerability_findings
4040
def cached_vulnerabilities_findings
4141
results = []
4242
project_ids_to_fetch.each do |project_id|
43-
results += Gitlab::Vulnerabilities::OccurenceCache.new(vulnerable, project_id).fetch
43+
results += Gitlab::Vulnerabilities::OccurenceCache.new(vulnerable, project_id, user).fetch
4444
end
4545

4646
results

ee/lib/gitlab/vulnerabilities/occurence_cache.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ def initialize(vulnerable, project_id, user)
1111
@user = user
1212
end
1313

14-
def fetch
14+
def fetch(force: false)
1515
Rails.cache.fetch(cache_key, force: force, expires_in: 1.day) do
1616
findings = ::Security::VulnerabilityFindingsFinder
1717
.new(vulnerable, params: { project_id: [project_id] })

0 commit comments

Comments
 (0)