From d14faa34fa81b66a6e44f54689f04560af26fa41 Mon Sep 17 00:00:00 2001 From: Chris Roos Date: Thu, 16 Nov 2023 12:19:21 +0000 Subject: [PATCH] Add test for SSO Push updates to emails_controller_test As far as I can tell we've been sending push updates (to the applications a user has access to) when a user's email changes since the functionality was added to Signon[1] and gds-sso[2] in 2012. Although we're still sending those push updates from the new `Users::EmailsController` (added in #2509) we weren't testing it in the controller test. I'm adding a test (copied from the previous commit) to avoid regressions in future. [1]: https://github.com/alphagov/signon/pull/6/commits/f339848ac0c98188b0fc746935324f59215d26f2 [2]: https://github.com/alphagov/gds-sso/commit/8c0888cda78b2d0323da26ff4c8da362074168d7 --- test/controllers/users/emails_controller_test.rb | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/controllers/users/emails_controller_test.rb b/test/controllers/users/emails_controller_test.rb index 9377e581f9..4e5c7aa382 100644 --- a/test/controllers/users/emails_controller_test.rb +++ b/test/controllers/users/emails_controller_test.rb @@ -166,6 +166,13 @@ class Users::EmailsControllerTest < ActionController::TestCase put :update, params: { user_id: user, user: { email: "user@gov.uk" } } end + should "push changes out to apps" do + user = create(:user) + PermissionUpdater.expects(:perform_on).with(user).once + + put :update, params: { user_id: user, user: { email: "new-user@gov.uk" } } + end + should "redirect to edit user page and display success notice" do user = create(:user, email: "user@gov.uk")