Commit bd2d5587 authored by celdem's avatar celdem

Fix severity level sorting without changing test

parent 2823acc2
......@@ -72,8 +72,8 @@ module Security
# will have highest severity
def sort_by_severity(collection)
collection.sort do |dep_i, dep_j|
level_i = dep_i.dig(:vulnerabilities, 0, :severity) || :unknown
level_j = dep_j.dig(:vulnerabilities, 0, :severity) || :unknown
level_i = dep_i.dig(:vulnerabilities, 0, :severity) || :info
level_j = dep_j.dig(:vulnerabilities, 0, :severity) || :info
::Vulnerabilities::Occurrence::SEVERITY_LEVELS[level_j] <=> ::Vulnerabilities::Occurrence::SEVERITY_LEVELS[level_i]
end
......
......@@ -117,7 +117,7 @@ describe Projects::DependenciesController do
it 'returns sorted list' do
expect(json_response['dependencies'].first['name']).to eq('nokogiri')
expect(json_response['dependencies'].second['name']).to eq('mini_portile2')
expect(json_response['dependencies'].second['name']).to eq('debug')
end
end
end
......
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