-
Notifications
You must be signed in to change notification settings - Fork 193
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9498741
commit 63fdaff
Showing
3 changed files
with
46 additions
and
68 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
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 |
---|---|---|
|
@@ -48,4 +48,45 @@ class Govspeak::RemoveAdvisoryServiceTest < ActiveSupport::TestCase | |
|
||
assert_equal expected, service.replace_all_advisories(edition.body) | ||
end | ||
|
||
test "replace_all_advisories will replace advisories with no space after the @" do | ||
body = "@This is a very important message or warning@" | ||
edition = create(:published_edition, body:) | ||
service = Govspeak::RemoveAdvisoryService.new(edition) | ||
|
||
expected = "^This is a very important message or warning^" | ||
|
||
assert_equal expected, service.replace_all_advisories(edition.body) | ||
end | ||
|
||
test "replace_all_advisories will replace advisories with no closing @" do | ||
body = "\r\n@ New online safety legislation is coming which will aim to reduce online harms.\r\n\r\n" | ||
edition = create(:published_edition, body:) | ||
service = Govspeak::RemoveAdvisoryService.new(edition) | ||
|
||
expected = "\r\n^ New online safety legislation is coming which will aim to reduce online harms.^\r\n\r\n" | ||
|
||
assert_equal expected, service.replace_all_advisories(edition.body) | ||
end | ||
|
||
test "replace_all_advisories will not replace anything resembling an email address" do | ||
body = "\r\nFor further information please get in touch at [email protected].\r\n\r\n" | ||
edition = create(:published_edition, body:) | ||
service = Govspeak::RemoveAdvisoryService.new(edition) | ||
|
||
expected = "\r\nFor further information please get in touch at [email protected].\r\n\r\n" | ||
|
||
assert_equal expected, service.replace_all_advisories(edition.body) | ||
end | ||
|
||
test "replace_all_advisories will not replace twitter handles" do | ||
# NB any instances of twitter handles at the start of a line have been handled separately | ||
body = "\r\nTo hear more you can follow us at on @foobar\r\n\r\n" | ||
edition = create(:published_edition, body:) | ||
service = Govspeak::RemoveAdvisoryService.new(edition) | ||
|
||
expected = "\r\nTo hear more you can follow us at on @foobar\r\n\r\n" | ||
|
||
assert_equal expected, service.replace_all_advisories(edition.body) | ||
end | ||
end |