File tree Expand file tree Collapse file tree 4 files changed +51
-12
lines changed
lib/action_dispatch/routing
railties/test/application Expand file tree Collapse file tree 4 files changed +51
-12
lines changed Original file line number Diff line number Diff line change 1- * Fixes multiple calls to ` logger.fatal ` instead of a single call,
2- for every line in an exception backtrace, when printing trace
1+ * Fixes Incorrect output from rails routes when using singular resources.
2+
3+ Fixes #26606
4+
5+ * Erick Reyna*
6+
7+ * Fixes multiple calls to ` logger.fatal ` instead of a single call,
8+ for every line in an exception backtrace, when printing trace
39 from ` DebugExceptions ` middleware.
4-
10+
511 Fixes #26134
612
713 * Vipul A M*
8-
14+
915* Add support for arbitrary hashes in strong parameters:
1016
1117 ``` ruby
Original file line number Diff line number Diff line change @@ -1244,11 +1244,11 @@ def resources_path_names(options)
12441244 # the plural):
12451245 #
12461246 # GET /profile/new
1247- # POST /profile
12481247 # GET /profile
12491248 # GET /profile/edit
12501249 # PATCH/PUT /profile
12511250 # DELETE /profile
1251+ # POST /profile
12521252 #
12531253 # === Options
12541254 # Takes same options as +resources+.
@@ -1266,15 +1266,15 @@ def resource(*resources, &block)
12661266
12671267 concerns ( options [ :concerns ] ) if options [ :concerns ]
12681268
1269- collection do
1270- post :create
1271- end if parent_resource . actions . include? ( :create )
1272-
12731269 new do
12741270 get :new
12751271 end if parent_resource . actions . include? ( :new )
12761272
12771273 set_member_mappings_for_resource
1274+
1275+ collection do
1276+ post :create
1277+ end if parent_resource . actions . include? ( :create )
12781278 end
12791279 end
12801280
Original file line number Diff line number Diff line change 1+ require "isolation/abstract_unit"
2+ require "active_support/core_ext/string/strip"
3+
4+ class RakeTest < ActiveSupport ::TestCase
5+ include ActiveSupport ::Testing ::Isolation
6+
7+ def setup
8+ build_app
9+ end
10+
11+ def teardown
12+ teardown_app
13+ end
14+
15+ def test_singular_resource_output_in_rake_routes
16+ app_file "config/routes.rb" , <<-RUBY
17+ Rails.application.routes.draw do
18+ resource :post
19+ end
20+ RUBY
21+ expected_output = [ " Prefix Verb URI Pattern Controller#Action" ,
22+ " new_post GET /post/new(.:format) posts#new" ,
23+ "edit_post GET /post/edit(.:format) posts#edit" ,
24+ " post GET /post(.:format) posts#show" ,
25+ " PATCH /post(.:format) posts#update" ,
26+ " PUT /post(.:format) posts#update" ,
27+ " DELETE /post(.:format) posts#destroy" ,
28+ " POST /post(.:format) posts#create\n " ] . join ( "\n " )
29+
30+ output = Dir . chdir ( app_path ) { `bin/rails routes -c PostController` }
31+ assert_equal expected_output , output
32+ end
33+ end
Original file line number Diff line number Diff line change @@ -159,13 +159,13 @@ def test_rails_routes_with_namespaced_controller_environment
159159 end
160160 RUBY
161161 expected_output = [ " Prefix Verb URI Pattern Controller#Action" ,
162- " admin_post POST /admin/post(.:format) admin/posts#create" ,
163162 " new_admin_post GET /admin/post/new(.:format) admin/posts#new" ,
164163 "edit_admin_post GET /admin/post/edit(.:format) admin/posts#edit" ,
165- " GET /admin/post(.:format) admin/posts#show" ,
164+ " admin_post GET /admin/post(.:format) admin/posts#show" ,
166165 " PATCH /admin/post(.:format) admin/posts#update" ,
167166 " PUT /admin/post(.:format) admin/posts#update" ,
168- " DELETE /admin/post(.:format) admin/posts#destroy\n " ] . join ( "\n " )
167+ " DELETE /admin/post(.:format) admin/posts#destroy" ,
168+ " POST /admin/post(.:format) admin/posts#create\n " ] . join ( "\n " )
169169
170170 output = Dir . chdir ( app_path ) { `bin/rails routes -c Admin::PostController` }
171171 assert_equal expected_output , output
You can’t perform that action at this time.
0 commit comments