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

Changing directories during the test breaks file loading when ran by itself

This commit is contained in:
Joshua Peek 2009-10-03 22:02:51 -05:00
parent 660eb068d3
commit 7eaed071a2
2 changed files with 22 additions and 32 deletions

View file

@ -51,6 +51,7 @@ I18n.backend.store_translations 'pt-BR', {}
ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures') FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
class ActionController::IntegrationTest < ActiveSupport::TestCase class ActionController::IntegrationTest < ActiveSupport::TestCase
def self.build_app(routes = nil) def self.build_app(routes = nil)

View file

@ -1,9 +1,8 @@
require 'abstract_unit' require 'abstract_unit'
module RenderFile module RenderFile
class BasicController < ActionController::Base class BasicController < ActionController::Base
self.view_paths = File.dirname(__FILE__) self.view_paths = File.dirname(__FILE__)
def index def index
render :file => File.join(File.dirname(__FILE__), *%w[.. .. fixtures test hello_world]) render :file => File.join(File.dirname(__FILE__), *%w[.. .. fixtures test hello_world])
@ -44,7 +43,7 @@ module RenderFile
end end
def without_file_key_with_locals def without_file_key_with_locals
path = File.expand_path('../../fixtures/test/render_file_with_locals.erb') path = FIXTURES.join('test/render_file_with_locals.erb').to_s
render path, :locals => {:secret => 'in the sauce'} render path, :locals => {:secret => 'in the sauce'}
end end
end end
@ -52,15 +51,6 @@ module RenderFile
class TestBasic < SimpleRouteCase class TestBasic < SimpleRouteCase
testing RenderFile::BasicController testing RenderFile::BasicController
def setup
@old_pwd = Dir.pwd
Dir.chdir(File.dirname(__FILE__))
end
def teardown
Dir.chdir(@old_pwd)
end
test "rendering simple template" do test "rendering simple template" do
get :index get :index
assert_response "Hello world!" assert_response "Hello world!"
@ -106,5 +96,4 @@ module RenderFile
assert_response "The secret is in the sauce\n" assert_response "The secret is in the sauce\n"
end end
end end
end end