Skip to content

Commit

Permalink
Don't create Zendesk account for new user requests
Browse files Browse the repository at this point in the history
This functionality was originally introduced 12 years ago, with no explanation
as to why it was needed: #22

It seems unnecessary to create Zendesk account for users who may not ever need
to raise Zendesk tickets.  When a Zendesk ticket is received, a Zendesk account
is automatically created for a user.

At present only name, email and organisation are set. Having this information
in Zendesk add little value, as organisation can be derived from email address.
The 'Change existing user request' doesn't update Zendesk accounts.  All those
properties can be updated by the users themselves (or us "Zendesk Agents") if
necessary (e.g. machinery of government changes).

Users can view Zendesk ticket they raised in Zendesk, which they access via a
link in Support app. The link takes them to the GDS Support Services Signing
page with instructions on how to get a password.  Once the user sets the
password their account is verified.

It removes the complexity and allows us to retried gds_zendesk gem, without the
need to create another endpoint.
  • Loading branch information
AgaDufrat committed Aug 12, 2024
1 parent 1260c5f commit 8c64eab
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 43 deletions.
9 changes: 1 addition & 8 deletions app/controllers/create_new_user_requests_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
23 changes: 1 addition & 22 deletions spec/controllers/create_new_user_requests_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: "[email protected]",
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
Expand All @@ -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
2 changes: 0 additions & 2 deletions spec/features/change_existing_user_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
end

scenario "changing user permissions" do
zendesk_has_user(email: "[email protected]", name: "Bob Fields")

ticket_request = expect_zendesk_to_receive_ticket(
"subject" => "Change an existing user's account",
"requester" => hash_including("name" => "John Smith", "email" => "[email protected]"),
Expand Down
10 changes: 0 additions & 10 deletions spec/features/create_new_user_requests_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
},
])

zendesk_has_no_user_with_email("[email protected]")

ticket_request = expect_zendesk_to_receive_ticket(
"subject" => "Create a new user account",
"requester" => hash_including("name" => "John Smith", "email" => "[email protected]"),
Expand All @@ -50,13 +48,6 @@
[Additional comments]
XXXX",
)

user_creation_request = stub_zendesk_user_creation(
email: "[email protected]",
name: "Bob Fields",
verified: true,
)

visit "/"

click_on "Create a new user"
Expand All @@ -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

0 comments on commit 8c64eab

Please sign in to comment.