[openstreetmap/openstreetmap-website] Split api_controller actions into their own controllers (#2160)

Andy Allan notifications at github.com
Thu Feb 28 15:26:13 UTC 2019


I've been planning on a refactoring of api-related controllers for a while. For further background reading, see https://github.com/gravitystorm/openstreetmap-website/issues/27.

I want to refactor the api-related controllers to inherit from a common controller (in the same way that regular controllers normally inherit from ApplicationController). The only convention that I found has this base controller named as "ApiController", but we're already using that name. So I thought about renaming our current ApiController, to free up the name for reuse, but I couldn't figure out a good descriptive name for the actions in the current ApiController. And then I realised that's because they are mostly unrelated to each other, and so I could split them into separate controllers instead.

So that's what this PR does - it splits the ApiController into separate controllers for each unrelated action.

I've chosen to put them in an "api" namespace (aka subdirectory) since I plan to do this for the rest of the api-related controllers. It is also the end-goal for other work that I'm doing on supporting multiple API versions (see https://github.com/gravitystorm/openstreetmap-website/issues/28), so creating the new controllers in the subdirectory should avoid further renaming.
You can view, comment on, or merge this pull request online at:

  https://github.com/openstreetmap/openstreetmap-website/pull/2160

-- Commit Summary --

  * Move the capabilities call out of api_controller
  * Move the trackpoints call into its own controller (and rename to tracepoints)
  * Rename api controller test files
  * Move the permissions call out of api_controller
  * Move the changes api to its own controller
  * Move map method to its own controller

-- File Changes --

    M app/abilities/ability.rb (6)
    A app/controllers/api/capabilities_controller.rb (21)
    A app/controllers/api/changes_controller.rb (57)
    A app/controllers/api/map_controller.rb (107)
    A app/controllers/api/permissions_controller.rb (27)
    A app/controllers/api/tracepoints_controller.rb (112)
    D app/controllers/api_controller.rb (279)
    R app/views/api/capabilities/show.builder (0)
    R app/views/api/permissions/show.builder (0)
    M config/routes.rb (14)
    A test/controllers/api/capabilities_controller_test.rb (35)
    A test/controllers/api/changes_controller_test.rb (106)
    A test/controllers/api/map_controller_test.rb (181)
    A test/controllers/api/permissions_controller_test.rb (51)
    A test/controllers/api/tracepoints_controller_test.rb (146)
    D test/controllers/api_controller_test.rb (435)

-- Patch Links --

https://github.com/openstreetmap/openstreetmap-website/pull/2160.patch
https://github.com/openstreetmap/openstreetmap-website/pull/2160.diff

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/2160
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.openstreetmap.org/pipermail/rails-dev/attachments/20190228/1bda2ef5/attachment.html>


More information about the rails-dev mailing list