Skip to content

Remove unused API endpoints and unused stubbing of Profile API #567

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: main
Choose a base branch
from

Conversation

floehopper
Copy link
Contributor

@floehopper floehopper commented Jul 8, 2025

I started making these changes when I noticed that a bunch of stubbing of ProfileApiClient methods was not needed.

However, I then noticed that a bunch of ProfileApiClient methods are no-ops, because they don't make any use of ProfileApiClient.connection which is the only code that actually makes any HTTP requests to the Profile API. This in turn led me to remove the API endpoints whose sole purpose was to call these no-op methods along with all the associated code and specs.

I can't see any reason to keep unused code in the app - it just makes the codebase harder to navigate for no good reason. If we envisage implementing these endpoints in the future and we're worried about having to write the same code again, we can easily recover it from the git history.

The API endpoints that have been removed are:

  • POST /api/schools/:school_id/owners
  • DELETE /api/schools/:school_id/owners/:id
  • DELETE /api/schools/:school_id/teachers/:id

As far as I can see, editor-standalone doesn't make requests to any URLs relating to school owners and the only requests it makes relating to school teachers is in inviteTeacherToSchool() - see the following references:

So it should be safe to merge this.

The `ProfileApiMock#stub_profile_api_list_school_students` helper method
stubs the `ProfileApiClient.list_school_students` method. However, none
of the examples in these specs result in a call to that method, so we
can remove the calls. Removing these redundant calls should make the
specs easier to reason about.
The `ProfileApiMock#stub_profile_api_list_school_owners` helper method
stubs the `ProfileApiClient.list_school_owners` method. However, none of
the examples in these specs result in a call to that method, so we can
remove the calls. Removing these redundant calls should make the specs
easier to reason about.
This method isn't called from anywhere in the code and, in any case,
it's a no-op, because it doesn't call `ProfileApiClient.connection`, so
it's safe to remove it.
I noticed that `ProfileApiClient.invite_school_owner` was a no-op,
because it didn't call `ProfileApiClient.connection`, so I've removed it
as well as the operation and the controller action that called it.
I noticed that `ProfileApiClient.remove_school_owner` was a no-op,
because it didn't call `ProfileApiClient.connection`, so I've removed it
as well as the operation and the controller action that called it.
I noticed that `ProfileApiClient.remove_school_teacher` was a no-op,
because it didn't call `ProfileApiClient.connection`, so I've removed it
as well as the operation and the controller action that called it.
@cla-bot cla-bot bot added the cla-signed label Jul 8, 2025
@raspberrypiherokubot raspberrypiherokubot temporarily deployed to editor-api-p-remove-unu-ev33tz July 8, 2025 15:40 Inactive
@floehopper floehopper marked this pull request as ready for review July 8, 2025 15:45
@floehopper
Copy link
Contributor Author

@adrian-rpf This addresses one of the issues I mentioned when we chatted the other day. I'd welcome your feedback.

Copy link
Contributor

@chrisroos chrisroos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This all looks good to me, @floehopper!

I've also double checked CEfE in staging and can't see any way in the UI to do any of the 3 operations you've removed:

  • Add an owner
  • Remove an owner
  • Remove a teacher

Which provides further evidence that this code isn't being exercised.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants