ohbarye/route_mechanic

All public methods in controllers are treated as action methods

Closed this issue · 2 comments

Issue

If there's a public method in a controller, route_mechanic treats it as an action method that should have routes.

e.g.

# If we have a method like below,
class UsersController
  def foo_helper
  end
end

# it expects `users#foo_helper` to exist in routes

Solution

TBA 🤔
Should users be able to ignore any action methods?

pocke commented

I think it is not a big problem because personally I think the helper/before_action should be private.
So the detected errors are "correct" for me.

On the other hand, it's easy to assume that someone wants to suppress them.
So I think the ignoring feature (or something else) will be a good feature.

By the way, I propose to divide the matcher into two.
For example:

# before
expect(Rails.application).to have_valid_routes

# after - it checks the same things.
expect(Rails.application).to have_no_unused_actions
expect(Rails.application).to have_no_unused_routes

# after - If we want to suppress unused actions
# expect(Rails.application).to have_no_unused_actions
expect(Rails.application).to have_no_unused_routes

Shipped new matchers in v0.2.0, based on proposal in #10 (comment). Thank you.