diff options
author | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 17:16:28 +0300 |
---|---|---|
committer | GitLab Bot <gitlab-bot@gitlab.com> | 2023-07-19 17:16:28 +0300 |
commit | e4384360a16dd9a19d4d2d25d0ef1f2b862ed2a6 (patch) | |
tree | 2fcdfa7dcdb9db8f5208b2562f4b4e803d671243 /spec/initializers/action_dispatch_journey_router_spec.rb | |
parent | ffda4e7bcac36987f936b4ba515995a6698698f0 (diff) |
Add latest changes from gitlab-org/gitlab@16-2-stable-eev16.2.0-rc42
Diffstat (limited to 'spec/initializers/action_dispatch_journey_router_spec.rb')
-rw-r--r-- | spec/initializers/action_dispatch_journey_router_spec.rb | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/spec/initializers/action_dispatch_journey_router_spec.rb b/spec/initializers/action_dispatch_journey_router_spec.rb new file mode 100644 index 00000000000..641a8c6d11f --- /dev/null +++ b/spec/initializers/action_dispatch_journey_router_spec.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +require 'spec_helper' + +# Adds a missing test to provide full coverage for the patch +RSpec.describe 'ActionDispatch::Journey::Router Patch', feature_category: :database do + before do + load Rails.root.join('config/initializers/action_dispatch_journey_router.rb') + end + + describe '#find_routes' do + context 'when a route has additional constrains' do + it 'does not raise an error' do + stub_const('PagesController', Class.new(ApplicationController)) + + set = ActionDispatch::Routing::RouteSet.new + + set.draw do + get "*namespace_id/:project_id/bar", + to: "pages#show", + constraints: { + namespace_id: %r{(?!api/)[a-zA-Z0-9_\\]+}, + project_id: /[a-zA-Z0-9]+/ + } + + get "/api/foo/bar", to: "pages#index" + end + + params = set.recognize_path("/api/foo/bar", method: :get) + + expect(params[:controller]).to eq('pages') + expect(params[:action]).to eq('index') + end + end + end +end |