Skip to content

Commit

Permalink
Would controller specs be better?
Browse files Browse the repository at this point in the history
  • Loading branch information
hannako committed Nov 12, 2024
1 parent f8d27fe commit 7135e31
Showing 1 changed file with 29 additions and 0 deletions.
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

0 comments on commit 7135e31

Please sign in to comment.