-
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.
- Loading branch information
Showing
1 changed file
with
29 additions
and
0 deletions.
There are no files selected for viewing
29 changes: 29 additions & 0 deletions
29
test/controllers/document_collection_email_notifications_controller_test.rb
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,29 @@ | ||
require "test_helper" | ||
|
||
class ContentItemsControllerTest < ActionController::TestCase | ||
include GdsApi::TestHelpers::ContentStore | ||
include GovukPersonalisation::TestHelpers::Requests | ||
|
||
test "the single page notification button POSTs to EmailAlertAPI's account-only endpoint for users logged into their gov.uk account" do | ||
content_item = content_store_has_schema_example("document_collection", "document_collection") | ||
stub_content_store_has_item(content_item["base_path"], content_item) | ||
path = content_item["base_path"][1..] | ||
|
||
mock_logged_in_session("session_id") | ||
get :show, params: { path: } | ||
|
||
assert response.body.include?("/email/subscriptions/single-page/new") | ||
assert response.body.include?("gem-c-single-page-notification-button") | ||
end | ||
|
||
test "the single page notification button POSTs to EmailAlertAPI's account-free endpoint if users do not have an active account session" do | ||
content_item = content_store_has_schema_example("document_collection", "document_collection") | ||
stub_content_store_has_item(content_item["base_path"], content_item) | ||
path = content_item["base_path"][1..] | ||
|
||
get :show, params: { path: } | ||
|
||
assert response.body.include?("/email-signup") | ||
assert response.body.include?("gem-c-single-page-notification-button") | ||
end | ||
end |