Skip to content

Commit

Permalink
Fix advisory detail icon missing in advisory detail page (#2947)
Browse files Browse the repository at this point in the history
* Fix advisory detail icon missing in advisory detail page

* Strip unknown case from advisory types
  • Loading branch information
dottorblaster authored Sep 6, 2024
1 parent 572a0c7 commit 5efe4a1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
1 change: 1 addition & 0 deletions lib/trento/software_updates/enums/advisory_type.ex
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ defmodule Trento.SoftwareUpdates.Enums.AdvisoryType do
def from_string(@security_advisory), do: security_advisory()
def from_string(@bugfix), do: bugfix()
def from_string(@enhancement), do: enhancement()
def from_string(_), do: bugfix()
end
5 changes: 4 additions & 1 deletion lib/trento_web/views/v1/suse_manager_view.ex
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
defmodule TrentoWeb.V1.SUSEManagerView do
use TrentoWeb, :view

alias Trento.SoftwareUpdates.Enums.AdvisoryType

def render("software_updates.json", %{
relevant_patches: relevant_patches,
upgradable_packages: upgradable_packages
Expand Down Expand Up @@ -74,7 +76,8 @@ defmodule TrentoWeb.V1.SUSEManagerView do
errata_details:
errata_details
|> Map.drop([:errataFrom])
|> Map.put(:errata_from, errataFrom),
|> Map.put(:errata_from, errataFrom)
|> Map.update(:type, "", &AdvisoryType.from_string/1),
cves: cves,
fixes: fixes,
affected_packages: affected_packages,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,6 @@ defmodule TrentoWeb.V1.SUSEManagerControllerTest do
release: release,
advisory_status: advisory_status,
vendor_advisory: vendor_advisory,
type: type,
product: product,
errataFrom: errata_from,
topic: topic,
Expand Down Expand Up @@ -210,7 +209,7 @@ defmodule TrentoWeb.V1.SUSEManagerControllerTest do
release: ^release,
advisory_status: ^advisory_status,
vendor_advisory: ^vendor_advisory,
type: ^type,
type: "bugfix",
product: ^product,
errata_from: ^errata_from,
topic: ^topic,
Expand Down
9 changes: 4 additions & 5 deletions test/trento_web/views/v1/suse_manager_view_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ defmodule TrentoWeb.V1.SUSEManagerViewTest do
test "should render relevant fields" do
%{errataFrom: errata_from} = errata_details = build(:errata_details)

errata_details_sans_errata_from = Map.delete(errata_details, :errataFrom)

expected_errata_details =
Map.put(errata_details_sans_errata_from, :errata_from, errata_from)
%{errata_details | type: :bugfix}
|> Map.delete(:errataFrom)
|> Map.put(:errata_from, errata_from)

cves = build_list(10, :cve)

Expand All @@ -45,8 +45,7 @@ defmodule TrentoWeb.V1.SUSEManagerViewTest do
affected_systems: ^affected_systems
} =
render(SUSEManagerView, "errata_details.json", %{
errata_details:
Map.put(errata_details_sans_errata_from, :errataFrom, errata_from),
errata_details: errata_details,
cves: cves,
fixes: fixes,
affected_packages: affected_packages,
Expand Down

0 comments on commit 5efe4a1

Please sign in to comment.