1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Ensure that rails templates methods are invoked with the proper extensions [#2531 status:resolved]

This commit is contained in:
José Valim 2009-07-04 17:34:48 +02:00
parent 8ff214e0db
commit 35925a8995
2 changed files with 29 additions and 6 deletions

View file

@ -78,7 +78,6 @@ module Rails
#
def environment(data=nil, options={}, &block)
sentinel = "Rails::Initializer.run do |config|"
data = block.call if !data && block_given?
in_root do
@ -214,9 +213,9 @@ module Rails
#
def rake(command, options={})
log :rake, command
env = options[:env] || 'development'
sudo = options[:sudo] ? 'sudo ' : ''
in_root { run("#{sudo}rake #{command} RAILS_ENV=#{env}", false) }
env = options[:env] || 'development'
sudo = options[:sudo] && RUBY_PLATFORM !~ /win32|mswin/ ? 'sudo ' : ''
in_root { run("#{sudo}#{extify(:rake)} #{command} RAILS_ENV=#{env}", false) }
end
# Just run the capify command in root
@ -227,7 +226,7 @@ module Rails
#
def capify!
log :capify, ""
in_root { run('capify .', false) }
in_root { run("#{extify(:capify)} .", false) }
end
# Add Rails to /vendor/rails
@ -238,7 +237,7 @@ module Rails
#
def freeze!(args = {})
log :vendor, "rails"
in_root { run('rake rails:freeze:edge', false) }
in_root { run("#{extify(:rake)} rails:freeze:edge", false) }
end
# Make an entry in Rails routing file conifg/routes.rb
@ -269,6 +268,12 @@ module Rails
end
end
# Add the ruby command extension to the given name.
#
def extify(name)
"#{name}#{File.extname(Thor::Util.ruby_command)}"
end
end
end
end

View file

@ -151,16 +151,34 @@ class ActionsTest < GeneratorsTestCase
action :rake, 'log:clear', :sudo => true
end
def test_rake_uses_ruby_extension
Thor::Util.expects(:ruby_command).returns('ruby.bat')
generator.expects(:run).once.with('rake.bat log:clear RAILS_ENV=development', false)
action :rake, 'log:clear'
end
def test_capify_should_run_the_capify_command
generator.expects(:run).once.with('capify .', false)
action :capify!
end
def test_capify_uses_ruby_extension
Thor::Util.expects(:ruby_command).returns('ruby.bat')
generator.expects(:run).once.with('capify.bat .', false)
action :capify!
end
def test_freeze_should_freeze_rails_edge
generator.expects(:run).once.with('rake rails:freeze:edge', false)
action :freeze!
end
def test_freeze_uses_ruby_extension
Thor::Util.expects(:ruby_command).returns('ruby.bat')
generator.expects(:run).once.with('rake.bat rails:freeze:edge', false)
action :freeze!
end
def test_route_should_add_data_to_the_routes_block_in_config_routes
run_generator
route_command = "map.route '/login', :controller => 'sessions', :action => 'new'"