Skip to content

Commit

Permalink
Fix rendering of unnumbered papers
Browse files Browse the repository at this point in the history
The "false" check in the unnumbered command and act papers was failing
because the component is passed an empty string rather than nil for the
number, which does not evaluate to false:

e.g.

a = false
!a
=> true
b = nil
!b
=> true
c = ""
!c
=> false

Therefore the check was returning `nil` rather than the "Unnumbered..."
text.
  • Loading branch information
leenagupte committed Apr 19, 2024
1 parent ef4e455 commit 55ae60d
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

## Unreleased

* Fix rendering of unnumbered papers ([PR #3988](https://github.com/alphagov/govuk_publishing_components/pull/3988))
* Add PDF specific icon to attachment component ([PR #3985](https://github.com/alphagov/govuk_publishing_components/pull/3985))
* Add the hidden attribute to mobile menu button ([PR #3975](https://github.com/alphagov/govuk_publishing_components/pull/3975))
* Add tool_name to GA4 feedback component tracking ([PR #3984](https://github.com/alphagov/govuk_publishing_components/pull/3984))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ def reference
end

def unnumbered_reference
unnumbered_reference = "Unnumbered command paper" if attachment_data[:unnumbered_command_paper].eql?(true) && !attachment_data[:command_paper_number]
unnumbered_reference = "Unnumbered act paper" if attachment_data[:unnumbered_hoc_paper].eql?(true) && !attachment_data[:hoc_paper_number]
unnumbered_reference = "Unnumbered command paper" if attachment_data[:unnumbered_command_paper].eql?(true) && attachment_data[:command_paper_number].blank?
unnumbered_reference = "Unnumbered act paper" if attachment_data[:unnumbered_hoc_paper].eql?(true) && attachment_data[:hoc_paper_number].blank?
unnumbered_reference
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@
title: "test",
url: "test",
content_type: "text/csv",
command_paper_number: "",
unnumbered_command_paper: true,
)
expect(attachment.unnumbered_reference).to eq("Unnumbered command paper")
Expand All @@ -185,6 +186,7 @@
title: "test",
url: "test",
content_type: "text/csv",
hoc_paper_number: "",
unnumbered_hoc_paper: true,
)
expect(attachment.unnumbered_reference).to eq("Unnumbered act paper")
Expand Down

0 comments on commit 55ae60d

Please sign in to comment.