-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2514 from alphagov/ga4-tracking-accordions
Add GA4 accordion tracking to manuals
- Loading branch information
Showing
6 changed files
with
102 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
module ManualsHelper | ||
def sanitize_manual_update_title(title) | ||
return "" if title.nil? | ||
|
||
strip_tags(title).gsub(I18n.t("manuals.updates_amendments"), "").gsub(/\s+/, " ").strip | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
require "test_helper" | ||
|
||
class ManualsHelperTest < ActionView::TestCase | ||
test "it returns an empty string when given an empty string" do | ||
expected = "" | ||
actual = "" | ||
assert_equal(expected, sanitize_manual_update_title(actual)) | ||
end | ||
|
||
test "it returns an empty string when given nil" do | ||
expected = "" | ||
actual = nil | ||
assert_equal(expected, sanitize_manual_update_title(actual)) | ||
end | ||
|
||
test "it removes HTML from the title" do | ||
expected = "Hello world" | ||
actual = " <h1> Hello world </h1> " | ||
assert_equal(expected, sanitize_manual_update_title(actual)) | ||
end | ||
|
||
test "it removes the manuals.updates_amendments string from the title" do | ||
expected = "Hello world" | ||
actual = " <h1> Hello world </h1> <span> #{I18n.t('manuals.updates_amendments')} </span> " | ||
assert_equal(expected, sanitize_manual_update_title(actual)) | ||
end | ||
|
||
test "it only the unrequired elements from the title" do | ||
expected = "Hello world ABC XYZ" | ||
actual = " <h1> Hello world </h1> <span> ABC #{I18n.t('manuals.updates_amendments')} XYZ </span> " | ||
assert_equal(expected, sanitize_manual_update_title(actual)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters