diff options
Diffstat (limited to 'railties/test')
-rw-r--r-- | railties/test/application/rake/restart_test.rb | 31 | ||||
-rw-r--r-- | railties/test/rails_info_controller_test.rb | 25 |
2 files changed, 56 insertions, 0 deletions
diff --git a/railties/test/application/rake/restart_test.rb b/railties/test/application/rake/restart_test.rb new file mode 100644 index 0000000000..35099913fb --- /dev/null +++ b/railties/test/application/rake/restart_test.rb @@ -0,0 +1,31 @@ +require "isolation/abstract_unit" + +module ApplicationTests + module RakeTests + class RakeRestartTest < ActiveSupport::TestCase + include ActiveSupport::Testing::Isolation + + def setup + build_app + boot_rails + end + + def teardown + teardown_app + end + + test 'rake restart touches tmp/restart.txt' do + Dir.chdir(app_path) do + `rake restart` + assert File.exist?("tmp/restart.txt") + + prev_mtime = File.mtime("tmp/restart.txt") + sleep(1) + `rake restart` + curr_mtime = File.mtime("tmp/restart.txt") + assert_not_equal prev_mtime, curr_mtime + end + end + end + end +end diff --git a/railties/test/rails_info_controller_test.rb b/railties/test/rails_info_controller_test.rb index 25b0e761cb..d87b51d852 100644 --- a/railties/test/rails_info_controller_test.rb +++ b/railties/test/rails_info_controller_test.rb @@ -53,4 +53,29 @@ class InfoControllerTest < ActionController::TestCase assert_response :success end + test "info controller returns exact matches" do + exact_count = -> { JSON(response.body)['exact'].size } + + get :routes, path: 'rails/info/route' + assert exact_count.call == 0, 'should not match incomplete routes' + + get :routes, path: 'rails/info/routes' + assert exact_count.call == 1, 'should match complete routes' + + get :routes, path: 'rails/info/routes.html' + assert exact_count.call == 1, 'should match complete routes with optional parts' + end + + test "info controller returns fuzzy matches" do + fuzzy_count = -> { JSON(response.body)['fuzzy'].size } + + get :routes, path: 'rails/info' + assert fuzzy_count.call == 2, 'should match incomplete routes' + + get :routes, path: 'rails/info/routes' + assert fuzzy_count.call == 1, 'should match complete routes' + + get :routes, path: 'rails/info/routes.html' + assert fuzzy_count.call == 0, 'should match optional parts of route literally' + end end |