Skip to content

Commit

Permalink
fix: accessible concern
Browse files Browse the repository at this point in the history
Some change in rails 7.2 made drawing of routes in an RSpec test not
play well with config.eager_load = true. Thus, in CI these tests would
fail.

Changed the way routes were dynamically added to fix.
  • Loading branch information
elasticspoon committed Sep 10, 2024
1 parent 571325a commit 4c97056
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 74 deletions.
70 changes: 0 additions & 70 deletions config/initializers/new_framework_defaults_7_2.rb

This file was deleted.

13 changes: 9 additions & 4 deletions spec/controllers/concerns/accessible_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,20 @@ def no_session_action
let(:volunteer) { create(:volunteer) }

context "Authenticated user" do
before do
Rails.application.reload_routes!
Rails.application.routes.disable_clear_and_finalize = true
around do |example|
Rails.application.routes.draw do
get :action, to: "mock#action"
get :no_session_action, to: "mock#no_session_action"

# required routes to make Accessible concern work
get :mock_admin, to: "admin#mock", as: :authenticated_all_casa_admin_root
get :mock_user, to: "user#mock", as: :authenticated_user_root
end

example.run

Rails.application.reload_routes!
end
after { Rails.application.routes_reloader.reload! }

it "should redirect to authenticated casa admin root path" do
allow(controller).to receive(:authenticate_user!).and_return(true)
Expand Down

0 comments on commit 4c97056

Please sign in to comment.