docbrown/spec/routing
Jeremy Friesen 765df66084
Scoping the :listing routes to feature (#16406)
This commit builds on the conditional rendering of navigation links by
adding a routing constraint to all :listing routes.

The impact is, if we were to disable the listing feature (e.g.,
`FeatureFlag.disable(:listing_feature_enabled)`) all requests to `GET
/listings` (and those drawn in the [config/routes/listings.rb][1] file)
would return a 404 response.

Related to forem/rfcs#291, #16335, #16338, #16362.

Testing this change:

1. Start your local application (e.g. `$ bin/startup`)
2. Go to http://localhost:3000/listings
3. You should get a Successful response.
4. Now disable the feature (e.g. `$ bin/rails r \
   "FeatureFlag.disable(:listing_feature_enabled)"`)
5. Refresh http://localhost:3000/listings
6. You should get an `ActiveRecord::RecordNotFound` error; because the
   application is now looking for a user or org named "listings"; in other
   words we're not routing `GET "/listings"` to `listings#index` controller
   action.
7. Now enable the feature (e.g. `$ bin/rails r \
   "FeatureFlag.enable(:listing_feature_enabled)"`)
8. Refresh http://localhost:3000/listings
9. You should get a Successful response.
10. Goto 4

This commit is intended to be the penultimate change before we toggle
the listings section off by default.

[1]:c2ce2c32d5/config/routes/listing.rb (L1)
2022-02-04 10:13:56 -05:00
..
all_routes_spec.rb Scoping the :listing routes to feature (#16406) 2022-02-04 10:13:56 -05:00
data_update_scripts_admin_routes_spec.rb Adds a feature flag for Data Update Scripts (#12641) 2021-02-10 18:22:27 +02:00
i18n_routes_spec.rb Add routes for i18n (#10193) 2020-09-03 17:11:07 -04:00
profile_admin_routes_spec.rb Replace calls to Flipper with FeatureFlag (#11386) 2020-11-12 14:15:33 +01:00