aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJoshua Peek <josh@joshpeek.com>2009-10-03 22:02:51 -0500
committerJoshua Peek <josh@joshpeek.com>2009-10-03 22:02:51 -0500
commit7eaed071a2c701552491767e42730cb6419cc6c3 (patch)
tree0c1bec58de1aeefc9b5f492acb51aca658734d7e
parent660eb068d3aaed0ad7769fe9b258d7e471972cbc (diff)
downloadrails-7eaed071a2c701552491767e42730cb6419cc6c3.tar.gz
rails-7eaed071a2c701552491767e42730cb6419cc6c3.tar.bz2
rails-7eaed071a2c701552491767e42730cb6419cc6c3.zip
Changing directories during the test breaks file loading when ran by itself
-rw-r--r--actionpack/test/abstract_unit.rb1
-rw-r--r--actionpack/test/controller/new_base/render_file_test.rb53
2 files changed, 22 insertions, 32 deletions
diff --git a/actionpack/test/abstract_unit.rb b/actionpack/test/abstract_unit.rb
index b72dd4dd0f..c1153b01de 100644
--- a/actionpack/test/abstract_unit.rb
+++ b/actionpack/test/abstract_unit.rb
@@ -51,6 +51,7 @@ I18n.backend.store_translations 'pt-BR', {}
ORIGINAL_LOCALES = I18n.available_locales.map {|locale| locale.to_s }.sort
FIXTURE_LOAD_PATH = File.join(File.dirname(__FILE__), 'fixtures')
+FIXTURES = Pathname.new(FIXTURE_LOAD_PATH)
class ActionController::IntegrationTest < ActiveSupport::TestCase
def self.build_app(routes = nil)
diff --git a/actionpack/test/controller/new_base/render_file_test.rb b/actionpack/test/controller/new_base/render_file_test.rb
index 1c52d2b37d..864469e0ae 100644
--- a/actionpack/test/controller/new_base/render_file_test.rb
+++ b/actionpack/test/controller/new_base/render_file_test.rb
@@ -1,110 +1,99 @@
require 'abstract_unit'
module RenderFile
-
class BasicController < ActionController::Base
- self.view_paths = File.dirname(__FILE__)
-
+ self.view_paths = File.dirname(__FILE__)
+
def index
render :file => File.join(File.dirname(__FILE__), *%w[.. .. fixtures test hello_world])
end
-
+
def with_instance_variables
@secret = 'in the sauce'
render :file => File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_ivar.erb')
end
-
+
def without_file_key
render File.join(File.dirname(__FILE__), *%w[.. .. fixtures test hello_world])
end
-
+
def without_file_key_with_instance_variable
@secret = 'in the sauce'
render File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_ivar.erb')
end
-
+
def relative_path
@secret = 'in the sauce'
render :file => '../../fixtures/test/render_file_with_ivar'
end
-
+
def relative_path_with_dot
@secret = 'in the sauce'
render :file => '../../fixtures/test/dot.directory/render_file_with_ivar'
end
-
+
def pathname
@secret = 'in the sauce'
render :file => Pathname.new(File.dirname(__FILE__)).join(*%w[.. .. fixtures test dot.directory render_file_with_ivar.erb])
end
-
+
def with_locals
path = File.join(File.dirname(__FILE__), '../../fixtures/test/render_file_with_locals.erb')
render :file => path, :locals => {:secret => 'in the sauce'}
end
-
+
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'}
end
end
-
+
class TestBasic < SimpleRouteCase
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
get :index
assert_response "Hello world!"
end
-
+
test "rendering template with ivar" do
get :with_instance_variables
assert_response "The secret is in the sauce\n"
end
-
+
test "rendering path without specifying the :file key" do
get :without_file_key
assert_response "Hello world!"
end
-
+
test "rendering path without specifying the :file key with ivar" do
get :without_file_key_with_instance_variable
assert_response "The secret is in the sauce\n"
end
-
+
test "rendering a relative path" do
get :relative_path
assert_response "The secret is in the sauce\n"
end
-
+
test "rendering a relative path with dot" do
get :relative_path_with_dot
assert_response "The secret is in the sauce\n"
end
-
+
test "rendering a Pathname" do
get :pathname
assert_response "The secret is in the sauce\n"
end
-
+
test "rendering file with locals" do
get :with_locals
assert_response "The secret is in the sauce\n"
end
-
+
test "rendering path without specifying the :file key with locals" do
get :without_file_key_with_locals
assert_response "The secret is in the sauce\n"
end
end
-
end