diff --git a/app/controllers/create_new_user_requests_controller.rb b/app/controllers/create_new_user_requests_controller.rb index 24bc5e0c..2a974e91 100644 --- a/app/controllers/create_new_user_requests_controller.rb +++ b/app/controllers/create_new_user_requests_controller.rb @@ -34,16 +34,9 @@ def create_or_change_user_request_params def save_to_zendesk(submitted_request) super - requested_user = Support::GDS::RequestedUser.new( + Support::GDS::RequestedUser.new( create_or_change_user_request_params.slice(:name, :email, :organisation), ) - create_or_update_user_in_zendesk(requested_user) - end - - def create_or_update_user_in_zendesk(requested_user) - GDS_ZENDESK_CLIENT.users.create_or_update_user(requested_user) - rescue ZendeskAPI::Error::ClientError => e - exception_notification_for(e) end def organisation_options diff --git a/spec/controllers/change_existing_user_requests_controller_spec.rb b/spec/controllers/change_existing_user_requests_controller_spec.rb index f4fb24ac..5a38ede4 100644 --- a/spec/controllers/change_existing_user_requests_controller_spec.rb +++ b/spec/controllers/change_existing_user_requests_controller_spec.rb @@ -21,7 +21,6 @@ def valid_change_user_request_params before do login_as create(:user_manager) - zendesk_has_no_user_with_email(@user.email) end it "submits the request to Zendesk" do diff --git a/spec/controllers/create_new_user_requests_controller_spec.rb b/spec/controllers/create_new_user_requests_controller_spec.rb index 11d8cabd..b814024b 100644 --- a/spec/controllers/create_new_user_requests_controller_spec.rb +++ b/spec/controllers/create_new_user_requests_controller_spec.rb @@ -26,26 +26,18 @@ def valid_create_user_request_params before do login_as create(:user_manager) - zendesk_has_no_user_with_email(@user.email) stub_support_api_organisations_list end - it "submits the request to Zendesk and creates a Zendesk user with the requested user details" do - zendesk_has_no_user_with_email(valid_requested_user_params["email"]) + it "submits the request to Zendesk" do stub_ticket_creation = stub_support_api_valid_raise_support_ticket( hash_including("tags" => %w[govt_form create_new_user]), ) - stub_user_creation = stub_zendesk_user_creation( - email: "subject@digital.cabinet-office.gov.uk", - name: "subject", - verified: true, - ) post :create, params: valid_create_user_request_params expect(request).to redirect_to("/acknowledge") expect(stub_ticket_creation).to have_been_made - expect(stub_user_creation).to have_been_made end it "re-displays the form with error messages if validation fails" do @@ -61,17 +53,4 @@ def valid_create_user_request_params expect(response.body).to have_css("select option[selected='selected'][value='Cabinet Office (CO)']") end - - it "doesn't expose an error to the user when automatic user creation goes wrong" do - zendesk_is_unavailable - - allow_any_instance_of(Zendesk::ZendeskTickets).to receive(:raise_ticket) - - expect(GovukError).to receive(:notify) - .with(kind_of(ZendeskAPI::Error::ClientError)) - - post :create, params: valid_create_user_request_params - - expect(response).to redirect_to("/acknowledge") - end end diff --git a/spec/features/change_existing_user_requests_spec.rb b/spec/features/change_existing_user_requests_spec.rb index 679c4a0b..036339db 100644 --- a/spec/features/change_existing_user_requests_spec.rb +++ b/spec/features/change_existing_user_requests_spec.rb @@ -12,8 +12,6 @@ end scenario "changing user permissions" do - zendesk_has_user(email: "bob@gov.uk", name: "Bob Fields") - ticket_request = expect_zendesk_to_receive_ticket( "subject" => "Change an existing user's account", "requester" => hash_including("name" => "John Smith", "email" => "john.smith@agency.gov.uk"), diff --git a/spec/features/create_new_user_requests_spec.rb b/spec/features/create_new_user_requests_spec.rb index 4ad5c747..b6460297 100644 --- a/spec/features/create_new_user_requests_spec.rb +++ b/spec/features/create_new_user_requests_spec.rb @@ -22,8 +22,6 @@ }, ]) - zendesk_has_no_user_with_email("bob@gov.uk") - ticket_request = expect_zendesk_to_receive_ticket( "subject" => "Create a new user account", "requester" => hash_including("name" => "John Smith", "email" => "john.smith@agency.gov.uk"), @@ -50,13 +48,6 @@ [Additional comments] XXXX", ) - - user_creation_request = stub_zendesk_user_creation( - email: "bob@gov.uk", - name: "Bob Fields", - verified: true, - ) - visit "/" click_on "Create a new user" @@ -73,6 +64,5 @@ user_submits_the_request_successfully expect(ticket_request).to have_been_made - expect(user_creation_request).to have_been_made end end