aboutsummaryrefslogtreecommitdiffstats
path: root/railties/test
diff options
context:
space:
mode:
authorRafael Mendonça França <rafaelmfranca@gmail.com>2012-11-13 13:51:19 -0800
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-11-13 13:51:19 -0800
commit3c5c93b2ebb9be715df2a34f150020dc7af73b15 (patch)
tree0b58e0878fdafd98fda9f7aa89d2f6e65f1311a0 /railties/test
parent8f6ce1a17ea1d73c3becc16ece79046e113daf8e (diff)
parentf945178a601f18c2c649fd925ca069da8c0f1547 (diff)
downloadrails-3c5c93b2ebb9be715df2a34f150020dc7af73b15.tar.gz
rails-3c5c93b2ebb9be715df2a34f150020dc7af73b15.tar.bz2
rails-3c5c93b2ebb9be715df2a34f150020dc7af73b15.zip
Merge pull request #8169 from nicolasdespres/robust_git_repository_check
Rake test:uncommitted finds git directory in ancestors.
Diffstat (limited to 'railties/test')
-rw-r--r--railties/test/application/rake_test.rb29
1 files changed, 29 insertions, 0 deletions
diff --git a/railties/test/application/rake_test.rb b/railties/test/application/rake_test.rb
index c5a68a5152..c6aea03d8c 100644
--- a/railties/test/application/rake_test.rb
+++ b/railties/test/application/rake_test.rb
@@ -106,6 +106,35 @@ module ApplicationTests
end
end
+ def test_rake_test_uncommitted_always_find_git_in_parent_dir
+ app_name = File.basename(app_path)
+ app_dir = File.dirname(app_path)
+ moved_app_name = app_name + '_moved'
+ moved_app_path = "#{app_path}/#{moved_app_name}"
+
+ Dir.chdir(app_dir) do
+ # Go from "./app/" to "./app/app_moved"
+ FileUtils.mv(app_name, moved_app_name)
+ FileUtils.mkdir(app_name)
+ FileUtils.mv(moved_app_name, app_name)
+ # Initialize the git repository and start the test.
+ Dir.chdir(app_name) do
+ `git init`
+ Dir.chdir(moved_app_name){ `rake db:migrate` }
+ silence_stderr { Dir.chdir(moved_app_name) { `rake test:uncommitted` } }
+ assert_equal 0, $?.exitstatus
+ end
+ end
+ end
+
+ def test_rake_test_uncommitted_fails_with_no_scm
+ Dir.chdir(app_path){ `rake db:migrate` }
+ Dir.chdir(app_path) do
+ silence_stderr { `rake test:uncommitted` }
+ assert_equal 1, $?.exitstatus
+ end
+ end
+
def test_rake_routes_calls_the_route_inspector
app_file "config/routes.rb", <<-RUBY
AppTemplate::Application.routes.draw do