aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/asset_debugging_test.rb3
-rw-r--r--railties/test/commands/routes_test.rb130
2 files changed, 72 insertions, 61 deletions
diff --git a/railties/test/application/asset_debugging_test.rb b/railties/test/application/asset_debugging_test.rb
index e56c7b958e..3e0f31860b 100644
--- a/railties/test/application/asset_debugging_test.rb
+++ b/railties/test/application/asset_debugging_test.rb
@@ -77,7 +77,8 @@ module ApplicationTests
stylesheet_link_tag: %r{<link rel="stylesheet" media="screen" href="/stylesheets/#{contents}.css" />},
javascript_include_tag: %r{<script src="/javascripts/#{contents}.js">},
audio_tag: %r{<audio src="/audios/#{contents}"></audio>},
- video_tag: %r{<video src="/videos/#{contents}"></video>}
+ video_tag: %r{<video src="/videos/#{contents}"></video>},
+ image_submit_tag: %r{<input type="image" src="/images/#{contents}" />}
}
cases.each do |(view_method, tag_match)|
diff --git a/railties/test/commands/routes_test.rb b/railties/test/commands/routes_test.rb
index b45fb05a6f..77ed2bda61 100644
--- a/railties/test/commands/routes_test.rb
+++ b/railties/test/commands/routes_test.rb
@@ -3,6 +3,7 @@
require "isolation/abstract_unit"
require "rails/command"
require "rails/commands/routes/routes_command"
+require "io/console/size"
class Rails::Command::RoutesTest < ActiveSupport::TestCase
setup :build_app
@@ -39,18 +40,18 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
output = run_routes_command(["-g", "show"])
assert_equal <<~MESSAGE, output
- Prefix Verb URI Pattern Controller#Action
- cart GET /cart(.:format) cart#show
- rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
- rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
- rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
+ Prefix Verb URI Pattern Controller#Action
+ cart GET /cart(.:format) cart#show
+ rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
+ rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
+ rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
MESSAGE
output = run_routes_command(["-g", "POST"])
assert_equal <<~MESSAGE, output
- Prefix Verb URI Pattern Controller#Action
- POST /cart(.:format) cart#create
- rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
+ Prefix Verb URI Pattern Controller#Action
+ POST /cart(.:format) cart#create
+ rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
MESSAGE
output = run_routes_command(["-g", "basketballs"])
@@ -60,10 +61,10 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
test "rails routes with controller search key" do
app_file "config/routes.rb", <<-RUBY
- Rails.application.routes.draw do
- get '/cart', to: 'cart#show'
- get '/basketball', to: 'basketball#index'
- end
+ Rails.application.routes.draw do
+ get '/cart', to: 'cart#show'
+ get '/basketball', to: 'basketball#index'
+ end
RUBY
output = run_routes_command(["-c", "cart"])
@@ -78,12 +79,13 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
test "rails routes with namespaced controller search key" do
app_file "config/routes.rb", <<-RUBY
- Rails.application.routes.draw do
- namespace :admin do
- resource :post
- end
+ Rails.application.routes.draw do
+ namespace :admin do
+ resource :post
end
+ end
RUBY
+
expected_output = [" Prefix Verb URI Pattern Controller#Action",
" new_admin_post GET /admin/post/new(.:format) admin/posts#new",
"edit_admin_post GET /admin/post/edit(.:format) admin/posts#edit",
@@ -102,60 +104,68 @@ class Rails::Command::RoutesTest < ActiveSupport::TestCase
test "rails routes displays message when no routes are defined" do
app_file "config/routes.rb", <<-RUBY
- Rails.application.routes.draw do
- end
+ Rails.application.routes.draw do
+ end
RUBY
assert_equal <<~MESSAGE, run_routes_command
- Prefix Verb URI Pattern Controller#Action
- rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
- rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
- rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
- update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
- rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
+ Prefix Verb URI Pattern Controller#Action
+ rails_service_blob GET /rails/active_storage/blobs/:signed_id/*filename(.:format) active_storage/blobs#show
+ rails_blob_representation GET /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
+ rails_disk_service GET /rails/active_storage/disk/:encoded_key/*filename(.:format) active_storage/disk#show
+ update_rails_disk_service PUT /rails/active_storage/disk/:encoded_token(.:format) active_storage/disk#update
+ rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format) active_storage/direct_uploads#create
MESSAGE
end
test "rails routes with expanded option" do
- app_file "config/routes.rb", <<-RUBY
+ begin
+ previous_console_winsize = IO.console.winsize
+ IO.console.winsize = [0, 27]
+
+ app_file "config/routes.rb", <<-RUBY
Rails.application.routes.draw do
get '/cart', to: 'cart#show'
end
- RUBY
-
- output = rails("routes", "--expanded")
- assert_equal <<~MESSAGE, output
- --[ Route 1 ]------------------------------------------------------------
- Prefix | cart
- Verb | GET
- URI | /cart(.:format)
- Controller#Action | cart#show
- --[ Route 2 ]------------------------------------------------------------
- Prefix | rails_service_blob
- Verb | GET
- URI | /rails/active_storage/blobs/:signed_id/*filename(.:format)
- Controller#Action | active_storage/blobs#show
- --[ Route 3 ]------------------------------------------------------------
- Prefix | rails_blob_representation
- Verb | GET
- URI | /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format)
- Controller#Action | active_storage/representations#show
- --[ Route 4 ]------------------------------------------------------------
- Prefix | rails_disk_service
- Verb | GET
- URI | /rails/active_storage/disk/:encoded_key/*filename(.:format)
- Controller#Action | active_storage/disk#show
- --[ Route 5 ]------------------------------------------------------------
- Prefix | update_rails_disk_service
- Verb | PUT
- URI | /rails/active_storage/disk/:encoded_token(.:format)
- Controller#Action | active_storage/disk#update
- --[ Route 6 ]------------------------------------------------------------
- Prefix | rails_direct_uploads
- Verb | POST
- URI | /rails/active_storage/direct_uploads(.:format)
- Controller#Action | active_storage/direct_uploads#create
- MESSAGE
+ RUBY
+
+ output = run_routes_command(["--expanded"])
+
+ assert_equal <<~MESSAGE, output
+ --[ Route 1 ]--------------
+ Prefix | cart
+ Verb | GET
+ URI | /cart(.:format)
+ Controller#Action | cart#show
+ --[ Route 2 ]--------------
+ Prefix | rails_service_blob
+ Verb | GET
+ URI | /rails/active_storage/blobs/:signed_id/*filename(.:format)
+ Controller#Action | active_storage/blobs#show
+ --[ Route 3 ]--------------
+ Prefix | rails_blob_representation
+ Verb | GET
+ URI | /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format)
+ Controller#Action | active_storage/representations#show
+ --[ Route 4 ]--------------
+ Prefix | rails_disk_service
+ Verb | GET
+ URI | /rails/active_storage/disk/:encoded_key/*filename(.:format)
+ Controller#Action | active_storage/disk#show
+ --[ Route 5 ]--------------
+ Prefix | update_rails_disk_service
+ Verb | PUT
+ URI | /rails/active_storage/disk/:encoded_token(.:format)
+ Controller#Action | active_storage/disk#update
+ --[ Route 6 ]--------------
+ Prefix | rails_direct_uploads
+ Verb | POST
+ URI | /rails/active_storage/direct_uploads(.:format)
+ Controller#Action | active_storage/direct_uploads#create
+ MESSAGE
+ ensure
+ IO.console.winsize = previous_console_winsize
+ end
end
private