Skip to content

Commit

Permalink
Still allow custom prefixed routes at Roda level
Browse files Browse the repository at this point in the history
Not calling `pass` would technically be a breaking change, no matter how
unlikely it would be for someone to define custom routes in Roda instead
of Rails.
  • Loading branch information
janko committed Oct 17, 2023
1 parent 8d087c5 commit 6e9f621
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
1 change: 1 addition & 0 deletions lib/rodauth/rails/app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ def rodauth(name = nil)
if prefix.present? && remaining_path == path_info
on prefix[1..-1] do
super
pass
end
else
super
Expand Down
8 changes: 6 additions & 2 deletions test/integration/configurations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ class ConfigurationsTest < IntegrationTest
assert_equal current_path, "/admin/login"
end

test "prefix with custom routes" do
visit "/admin/custom"
test "prefix with custom Roda router" do
visit "/admin/custom1"
assert_equal "Custom admin route", page.html
end

test "prefix with custom Rails route" do
visit "/admin/custom2"
assert_equal "Custom admin route", page.html
end
end
1 change: 1 addition & 0 deletions test/rails_app/app/misc/rodauth_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class RodauthApp < Rodauth::Rails::App
r.on("json") { r.rodauth(:json) }

r.on("assets") { "" }
r.get("admin/custom1") { "Custom admin route" }

if r.path == rails_routes.auth1_path
rodauth.require_account
Expand Down
2 changes: 1 addition & 1 deletion test/rails_app/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
get :roda
end

get "/admin/custom" => "admin/rodauth#custom"
get "/admin/custom2" => "admin/rodauth#custom"

constraints Rodauth::Rails.authenticate do
get "/authenticated" => "test#root"
Expand Down

0 comments on commit 6e9f621

Please sign in to comment.