Skip to content

Commit

Permalink
Merge pull request #1436 from alphagov/dont-create-zendesk-users
Browse files Browse the repository at this point in the history
Don't create Zendesk account for new user requests
  • Loading branch information
AgaDufrat authored Aug 14, 2024
2 parents bdec7fd + 8c64eab commit 42254d0
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 42254d0

Please sign in to comment.