mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Set precompiled fixture load path constant to speed up tests
This commit is contained in:
parent
a9259ccfe0
commit
339491a6b3
16 changed files with 182 additions and 192 deletions
|
@ -22,6 +22,7 @@ ActiveSupport::Deprecation.debug = true
|
|||
ActionController::Base.logger = nil
|
||||
ActionController::Routing::Routes.reload rescue nil
|
||||
|
||||
FIXTURE_LOAD_PATH = ActionView::ViewLoadPaths::LoadPath.new(File.join(File.dirname(__FILE__), 'fixtures'))
|
||||
|
||||
# Wrap tests that use Mocha and skip if unavailable.
|
||||
def uses_mocha(test_name)
|
||||
|
|
|
@ -30,7 +30,6 @@ end
|
|||
$stderr.flush
|
||||
|
||||
|
||||
|
||||
# Define the rest of the connector
|
||||
class ActiveRecordTestConnector
|
||||
class << self
|
||||
|
@ -48,46 +47,45 @@ class ActiveRecordTestConnector
|
|||
end
|
||||
|
||||
private
|
||||
def setup_connection
|
||||
if Object.const_defined?(:ActiveRecord)
|
||||
defaults = { :database => ':memory:' }
|
||||
begin
|
||||
options = defaults.merge :adapter => 'sqlite3', :timeout => 500
|
||||
ActiveRecord::Base.establish_connection(options)
|
||||
ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options }
|
||||
ActiveRecord::Base.connection
|
||||
rescue Exception # errors from establishing a connection
|
||||
$stderr.puts 'SQLite 3 unavailable; trying SQLite 2.'
|
||||
options = defaults.merge :adapter => 'sqlite'
|
||||
ActiveRecord::Base.establish_connection(options)
|
||||
ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options }
|
||||
ActiveRecord::Base.connection
|
||||
end
|
||||
|
||||
def setup_connection
|
||||
if Object.const_defined?(:ActiveRecord)
|
||||
defaults = { :database => ':memory:' }
|
||||
begin
|
||||
options = defaults.merge :adapter => 'sqlite3', :timeout => 500
|
||||
ActiveRecord::Base.establish_connection(options)
|
||||
ActiveRecord::Base.configurations = { 'sqlite3_ar_integration' => options }
|
||||
ActiveRecord::Base.connection
|
||||
rescue Exception # errors from establishing a connection
|
||||
$stderr.puts 'SQLite 3 unavailable; trying SQLite 2.'
|
||||
options = defaults.merge :adapter => 'sqlite'
|
||||
ActiveRecord::Base.establish_connection(options)
|
||||
ActiveRecord::Base.configurations = { 'sqlite2_ar_integration' => options }
|
||||
ActiveRecord::Base.connection
|
||||
Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE)
|
||||
else
|
||||
raise "Can't setup connection since ActiveRecord isn't loaded."
|
||||
end
|
||||
|
||||
Object.send(:const_set, :QUOTED_TYPE, ActiveRecord::Base.connection.quote_column_name('type')) unless Object.const_defined?(:QUOTED_TYPE)
|
||||
else
|
||||
raise "Can't setup connection since ActiveRecord isn't loaded."
|
||||
end
|
||||
end
|
||||
|
||||
# Load actionpack sqlite tables
|
||||
def load_schema
|
||||
File.read(File.dirname(__FILE__) + "/fixtures/db_definitions/sqlite.sql").split(';').each do |sql|
|
||||
ActiveRecord::Base.connection.execute(sql) unless sql.blank?
|
||||
# Load actionpack sqlite tables
|
||||
def load_schema
|
||||
File.read(File.dirname(__FILE__) + "/fixtures/db_definitions/sqlite.sql").split(';').each do |sql|
|
||||
ActiveRecord::Base.connection.execute(sql) unless sql.blank?
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def require_fixture_models
|
||||
Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f}
|
||||
end
|
||||
def require_fixture_models
|
||||
Dir.glob(File.dirname(__FILE__) + "/fixtures/*.rb").each {|f| require f}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class ActiveRecordTestCase < ActiveSupport::TestCase
|
||||
# Set our fixture path
|
||||
if ActiveRecordTestConnector.able_to_connect
|
||||
self.fixture_path = "#{File.dirname(__FILE__)}/fixtures/"
|
||||
self.fixture_path = [FIXTURE_LOAD_PATH]
|
||||
self.use_transactional_fixtures = false
|
||||
end
|
||||
|
||||
|
|
|
@ -40,11 +40,12 @@ class RenderPartialWithRecordIdentificationController < ActionController::Base
|
|||
render :partial => @developers
|
||||
end
|
||||
end
|
||||
RenderPartialWithRecordIdentificationController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
|
||||
RenderPartialWithRecordIdentificationController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
|
||||
fixtures :developers, :projects, :developers_projects, :topics, :replies, :companies, :mascots
|
||||
|
||||
|
||||
def setup
|
||||
@controller = RenderPartialWithRecordIdentificationController.new
|
||||
@request = ActionController::TestRequest.new
|
||||
|
@ -56,22 +57,22 @@ class RenderPartialWithRecordIdentificationTest < ActiveRecordTestCase
|
|||
get :render_with_has_many_and_belongs_to_association
|
||||
assert_template 'projects/_project'
|
||||
end
|
||||
|
||||
|
||||
def test_rendering_partial_with_has_many_association
|
||||
get :render_with_has_many_association
|
||||
assert_template 'replies/_reply'
|
||||
end
|
||||
|
||||
|
||||
def test_rendering_partial_with_named_scope
|
||||
get :render_with_named_scope
|
||||
assert_template 'replies/_reply'
|
||||
end
|
||||
|
||||
|
||||
def test_render_with_record
|
||||
get :render_with_record
|
||||
assert_template 'developers/_developer'
|
||||
end
|
||||
|
||||
|
||||
def test_render_with_record_collection
|
||||
get :render_with_record_collection
|
||||
assert_template 'developers/_developer'
|
||||
|
@ -116,7 +117,8 @@ class RenderPartialWithRecordIdentificationController < ActionController::Base
|
|||
render :partial => @developers
|
||||
end
|
||||
end
|
||||
RenderPartialWithRecordIdentificationController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
|
||||
RenderPartialWithRecordIdentificationController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class Game < Struct.new(:name, :id)
|
||||
def to_param
|
||||
|
@ -134,7 +136,8 @@ module Fun
|
|||
render :partial => [ Game.new("Pong"), Game.new("Tank") ]
|
||||
end
|
||||
end
|
||||
NestedController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
|
||||
NestedController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
module Serious
|
||||
class NestedDeeperController < ActionController::Base
|
||||
|
@ -146,7 +149,8 @@ module Fun
|
|||
render :partial => [ Game.new("Chess"), Game.new("Sudoku"), Game.new("Solitaire") ]
|
||||
end
|
||||
end
|
||||
NestedDeeperController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
|
||||
NestedDeeperController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -167,7 +171,6 @@ class RenderPartialWithRecordIdentificationAndNestedControllersTest < ActiveReco
|
|||
get :render_with_record_collection_in_nested_controller
|
||||
assert_template 'fun/games/_game'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
class RenderPartialWithRecordIdentificationAndNestedDeeperControllersTest < ActiveRecordTestCase
|
||||
|
@ -187,5 +190,4 @@ class RenderPartialWithRecordIdentificationAndNestedDeeperControllersTest < Acti
|
|||
get :render_with_record_collection_in_deeper_nested_controller
|
||||
assert_template 'fun/serious/games/_game'
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
@ -157,7 +157,7 @@ module Admin
|
|||
def redirect_to_fellow_controller
|
||||
redirect_to :controller => 'user'
|
||||
end
|
||||
|
||||
|
||||
def redirect_to_top_level_named_route
|
||||
redirect_to top_level_url(:id => "foo")
|
||||
end
|
||||
|
@ -170,7 +170,7 @@ end
|
|||
# tell the controller where to find its templates but start from parent
|
||||
# directory of test_request_response to simulate the behaviour of a
|
||||
# production environment
|
||||
ActionPackAssertionsController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
ActionPackAssertionsController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
# a test case to exercise the new capabilities TestRequest & TestResponse
|
||||
class ActionPackAssertionsControllerTest < Test::Unit::TestCase
|
||||
|
@ -533,7 +533,6 @@ class ActionPackHeaderTest < Test::Unit::TestCase
|
|||
assert_equal('application/pdf; charset=utf-8', @response.headers['type'])
|
||||
end
|
||||
|
||||
|
||||
def test_render_text_with_custom_content_type
|
||||
get :render_text_with_custom_content_type
|
||||
assert_equal 'application/rss+xml; charset=utf-8', @response.headers['type']
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
require 'abstract_unit'
|
||||
|
||||
class Address
|
||||
|
||||
def Address.count(conditions = nil, join = nil)
|
||||
nil
|
||||
end
|
||||
|
@ -20,7 +19,7 @@ class AddressesTestController < ActionController::Base
|
|||
def self.controller_path; "addresses"; end
|
||||
end
|
||||
|
||||
AddressesTestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
AddressesTestController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class AddressesTest < Test::Unit::TestCase
|
||||
def setup
|
||||
|
|
|
@ -6,7 +6,7 @@ CACHE_DIR = 'test_cache'
|
|||
FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/', CACHE_DIR)
|
||||
ActionController::Base.page_cache_directory = FILE_STORE_PATH
|
||||
ActionController::Base.cache_store = :file_store, FILE_STORE_PATH
|
||||
ActionController::Base.view_paths = [ File.dirname(__FILE__) + '/../fixtures/' ]
|
||||
ActionController::Base.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class PageCachingTestController < ActionController::Base
|
||||
caches_page :ok, :no_content, :if => Proc.new { |c| !c.request.format.json? }
|
||||
|
@ -631,7 +631,7 @@ class FunctionalCachingController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
FunctionalCachingController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
FunctionalCachingController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class FunctionalFragmentCachingTest < Test::Unit::TestCase
|
||||
def setup
|
||||
|
@ -642,6 +642,7 @@ class FunctionalFragmentCachingTest < Test::Unit::TestCase
|
|||
@request = ActionController::TestRequest.new
|
||||
@response = ActionController::TestResponse.new
|
||||
end
|
||||
|
||||
def test_fragment_caching
|
||||
get :fragment_cached
|
||||
assert_response :success
|
||||
|
|
|
@ -23,7 +23,7 @@ class CaptureController < ActionController::Base
|
|||
def rescue_action(e) raise end
|
||||
end
|
||||
|
||||
CaptureController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
CaptureController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class CaptureTest < Test::Unit::TestCase
|
||||
def setup
|
||||
|
|
|
@ -13,12 +13,12 @@ class ContentTypeController < ActionController::Base
|
|||
def render_content_type_from_render
|
||||
render :text => "hello world!", :content_type => Mime::RSS
|
||||
end
|
||||
|
||||
|
||||
def render_charset_from_body
|
||||
response.charset = "utf-16"
|
||||
render :text => "hello world!"
|
||||
end
|
||||
|
||||
|
||||
def render_default_for_rhtml
|
||||
end
|
||||
|
||||
|
@ -45,7 +45,7 @@ class ContentTypeController < ActionController::Base
|
|||
def rescue_action(e) raise end
|
||||
end
|
||||
|
||||
ContentTypeController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
ContentTypeController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class ContentTypeTest < Test::Unit::TestCase
|
||||
def setup
|
||||
|
@ -68,7 +68,7 @@ class ContentTypeTest < Test::Unit::TestCase
|
|||
def test_render_changed_charset_default
|
||||
ContentTypeController.default_charset = "utf-16"
|
||||
get :render_defaults
|
||||
assert_equal "utf-16", @response.charset
|
||||
assert_equal "utf-16", @response.charset
|
||||
assert_equal Mime::HTML, @response.content_type
|
||||
ContentTypeController.default_charset = "utf-8"
|
||||
end
|
||||
|
@ -76,13 +76,13 @@ class ContentTypeTest < Test::Unit::TestCase
|
|||
def test_content_type_from_body
|
||||
get :render_content_type_from_body
|
||||
assert_equal "application/rss+xml", @response.content_type
|
||||
assert_equal "utf-8", @response.charset
|
||||
assert_equal "utf-8", @response.charset
|
||||
end
|
||||
|
||||
def test_content_type_from_render
|
||||
get :render_content_type_from_render
|
||||
assert_equal "application/rss+xml", @response.content_type
|
||||
assert_equal "utf-8", @response.charset
|
||||
assert_equal "utf-8", @response.charset
|
||||
end
|
||||
|
||||
def test_charset_from_body
|
||||
|
@ -94,27 +94,27 @@ class ContentTypeTest < Test::Unit::TestCase
|
|||
def test_default_for_rhtml
|
||||
get :render_default_for_rhtml
|
||||
assert_equal Mime::HTML, @response.content_type
|
||||
assert_equal "utf-8", @response.charset
|
||||
assert_equal "utf-8", @response.charset
|
||||
end
|
||||
|
||||
def test_default_for_rxml
|
||||
get :render_default_for_rxml
|
||||
assert_equal Mime::XML, @response.content_type
|
||||
assert_equal "utf-8", @response.charset
|
||||
assert_equal "utf-8", @response.charset
|
||||
end
|
||||
|
||||
def test_default_for_rjs
|
||||
xhr :post, :render_default_for_rjs
|
||||
assert_equal Mime::JS, @response.content_type
|
||||
assert_equal "utf-8", @response.charset
|
||||
assert_equal "utf-8", @response.charset
|
||||
end
|
||||
|
||||
def test_change_for_rxml
|
||||
get :render_change_for_rxml
|
||||
assert_equal Mime::HTML, @response.content_type
|
||||
assert_equal "utf-8", @response.charset
|
||||
assert_equal "utf-8", @response.charset
|
||||
end
|
||||
|
||||
|
||||
def test_render_default_content_types_for_respond_to
|
||||
@request.env["HTTP_ACCEPT"] = Mime::HTML.to_s
|
||||
get :render_default_content_types_for_respond_to
|
||||
|
@ -130,7 +130,7 @@ class ContentTypeTest < Test::Unit::TestCase
|
|||
get :render_default_content_types_for_respond_to
|
||||
assert_equal Mime::XML, @response.content_type
|
||||
end
|
||||
|
||||
|
||||
def test_render_default_content_types_for_respond_to_with_overwrite
|
||||
@request.env["HTTP_ACCEPT"] = Mime::RSS.to_s
|
||||
get :render_default_content_types_for_respond_to
|
||||
|
|
|
@ -2,7 +2,6 @@ require 'abstract_unit'
|
|||
|
||||
class DeprecatedBaseMethodsTest < Test::Unit::TestCase
|
||||
class Target < ActionController::Base
|
||||
|
||||
def home_url(greeting)
|
||||
"http://example.com/#{greeting}"
|
||||
end
|
||||
|
@ -14,7 +13,7 @@ class DeprecatedBaseMethodsTest < Test::Unit::TestCase
|
|||
def rescue_action(e) raise e end
|
||||
end
|
||||
|
||||
Target.view_paths = [ File.dirname(__FILE__) + "/../../fixtures" ]
|
||||
Target.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
def setup
|
||||
@request = ActionController::TestRequest.new
|
||||
|
|
|
@ -107,7 +107,7 @@ class RespondToController < ActionController::Base
|
|||
type.any(:js, :xml) { render :text => "Either JS or XML" }
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def handle_any_any
|
||||
respond_to do |type|
|
||||
type.html { render :text => 'HTML' }
|
||||
|
@ -120,12 +120,12 @@ class RespondToController < ActionController::Base
|
|||
type.html
|
||||
type.js
|
||||
end
|
||||
end
|
||||
|
||||
def iphone_with_html_response_type
|
||||
end
|
||||
|
||||
def iphone_with_html_response_type
|
||||
Mime::Type.register_alias("text/html", :iphone)
|
||||
request.format = :iphone if request.env["HTTP_ACCEPT"] == "text/iphone"
|
||||
|
||||
|
||||
respond_to do |type|
|
||||
type.html { @type = "Firefox" }
|
||||
type.iphone { @type = "iPhone" }
|
||||
|
@ -138,7 +138,7 @@ class RespondToController < ActionController::Base
|
|||
def iphone_with_html_response_type_without_layout
|
||||
Mime::Type.register_alias("text/html", :iphone)
|
||||
request.format = "iphone" if request.env["HTTP_ACCEPT"] == "text/iphone"
|
||||
|
||||
|
||||
respond_to do |type|
|
||||
type.html { @type = "Firefox"; render :action => "iphone_with_html_response_type" }
|
||||
type.iphone { @type = "iPhone" ; render :action => "iphone_with_html_response_type" }
|
||||
|
@ -162,7 +162,7 @@ class RespondToController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
RespondToController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
RespondToController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class MimeControllerTest < Test::Unit::TestCase
|
||||
def setup
|
||||
|
@ -247,7 +247,7 @@ class MimeControllerTest < Test::Unit::TestCase
|
|||
get :just_xml
|
||||
assert_equal 'XML', @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_using_defaults
|
||||
@request.env["HTTP_ACCEPT"] = "*/*"
|
||||
get :using_defaults
|
||||
|
@ -347,12 +347,12 @@ class MimeControllerTest < Test::Unit::TestCase
|
|||
get :handle_any_any
|
||||
assert_equal 'HTML', @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_handle_any_any_parameter_format
|
||||
get :handle_any_any, {:format=>'html'}
|
||||
assert_equal 'HTML', @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_handle_any_any_explicit_html
|
||||
@request.env["HTTP_ACCEPT"] = "text/html"
|
||||
get :handle_any_any
|
||||
|
@ -364,7 +364,7 @@ class MimeControllerTest < Test::Unit::TestCase
|
|||
get :handle_any_any
|
||||
assert_equal 'Whatever you ask for, I got it', @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_handle_any_any_xml
|
||||
@request.env["HTTP_ACCEPT"] = "text/xml"
|
||||
get :handle_any_any
|
||||
|
@ -445,31 +445,31 @@ class MimeControllerTest < Test::Unit::TestCase
|
|||
|
||||
get :using_defaults, :format => "xml"
|
||||
assert_equal "using_defaults - xml", @response.body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_format_with_custom_response_type
|
||||
get :iphone_with_html_response_type
|
||||
assert_equal '<html><div id="html">Hello future from Firefox!</div></html>', @response.body
|
||||
|
||||
assert_equal '<html><div id="html">Hello future from Firefox!</div></html>', @response.body
|
||||
|
||||
get :iphone_with_html_response_type, :format => "iphone"
|
||||
assert_equal "text/html", @response.content_type
|
||||
assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def test_format_with_custom_response_type_and_request_headers
|
||||
@request.env["HTTP_ACCEPT"] = "text/iphone"
|
||||
get :iphone_with_html_response_type
|
||||
assert_equal '<html><div id="iphone">Hello iPhone future from iPhone!</div></html>', @response.body
|
||||
assert_equal "text/html", @response.content_type
|
||||
end
|
||||
end
|
||||
|
||||
def test_format_with_custom_response_type_and_request_headers_with_only_one_layout_present
|
||||
get :iphone_with_html_response_type_without_layout
|
||||
assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body
|
||||
assert_equal '<html><div id="html_missing">Hello future from Firefox!</div></html>', @response.body
|
||||
|
||||
@request.env["HTTP_ACCEPT"] = "text/iphone"
|
||||
assert_raises(ActionView::MissingTemplate) { get :iphone_with_html_response_type_without_layout }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
class AbstractPostController < ActionController::Base
|
||||
|
@ -497,7 +497,7 @@ class PostController < AbstractPostController
|
|||
end
|
||||
end
|
||||
|
||||
class SuperPostController < PostController
|
||||
class SuperPostController < PostController
|
||||
def index
|
||||
respond_to do |type|
|
||||
type.html
|
||||
|
@ -514,25 +514,24 @@ class MimeControllerLayoutsTest < Test::Unit::TestCase
|
|||
@controller = PostController.new
|
||||
@request.host = "www.example.com"
|
||||
end
|
||||
|
||||
|
||||
def test_missing_layout_renders_properly
|
||||
get :index
|
||||
assert_equal '<html><div id="html">Hello Firefox</div></html>', @response.body
|
||||
assert_equal '<html><div id="html">Hello Firefox</div></html>', @response.body
|
||||
|
||||
@request.env["HTTP_ACCEPT"] = "text/iphone"
|
||||
get :index
|
||||
assert_equal 'Hello iPhone', @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_format_with_inherited_layouts
|
||||
@controller = SuperPostController.new
|
||||
|
||||
|
||||
get :index
|
||||
assert_equal 'Super Firefox', @response.body
|
||||
|
||||
|
||||
@request.env["HTTP_ACCEPT"] = "text/iphone"
|
||||
get :index
|
||||
assert_equal '<html><div id="super_iphone">Super iPhone</div></html>', @response.body
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
@ -45,11 +45,11 @@ class NewRenderTestController < ActionController::Base
|
|||
def render_action_hello_world_as_symbol
|
||||
render :action => :hello_world
|
||||
end
|
||||
|
||||
|
||||
def render_text_hello_world
|
||||
render :text => "hello world"
|
||||
end
|
||||
|
||||
|
||||
def render_text_hello_world_with_layout
|
||||
@variable_for_layout = ", I'm here!"
|
||||
render :text => "hello world", :layout => true
|
||||
|
@ -68,7 +68,7 @@ class NewRenderTestController < ActionController::Base
|
|||
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb')
|
||||
render :file => path
|
||||
end
|
||||
|
||||
|
||||
def render_file_from_template
|
||||
@secret = 'in the sauce'
|
||||
@path = File.expand_path(File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_ivar.erb'))
|
||||
|
@ -76,14 +76,14 @@ class NewRenderTestController < ActionController::Base
|
|||
|
||||
def render_file_with_locals
|
||||
path = File.join(File.dirname(__FILE__), '../fixtures/test/render_file_with_locals.erb')
|
||||
render :file => path, :locals => {:secret => 'in the sauce'}
|
||||
render :file => path, :locals => {:secret => 'in the sauce'}
|
||||
end
|
||||
|
||||
def render_file_not_using_full_path
|
||||
@secret = 'in the sauce'
|
||||
render :file => 'test/render_file_with_ivar', :use_full_path => true
|
||||
end
|
||||
|
||||
|
||||
def render_file_not_using_full_path_with_dot_in_path
|
||||
@secret = 'in the sauce'
|
||||
render :file => 'test/dot.directory/render_file_with_ivar', :use_full_path => true
|
||||
|
@ -105,7 +105,7 @@ class NewRenderTestController < ActionController::Base
|
|||
def layout_test_with_different_layout
|
||||
render :action => "hello_world", :layout => "standard"
|
||||
end
|
||||
|
||||
|
||||
def rendering_without_layout
|
||||
render :action => "hello_world", :layout => false
|
||||
end
|
||||
|
@ -113,11 +113,11 @@ class NewRenderTestController < ActionController::Base
|
|||
def layout_overriding_layout
|
||||
render :action => "hello_world", :layout => "standard"
|
||||
end
|
||||
|
||||
|
||||
def rendering_nothing_on_layout
|
||||
render :nothing => true
|
||||
end
|
||||
|
||||
|
||||
def builder_layout_test
|
||||
render :action => "hello"
|
||||
end
|
||||
|
@ -135,9 +135,9 @@ class NewRenderTestController < ActionController::Base
|
|||
def partial_only_with_layout
|
||||
render :partial => "partial_only", :layout => true
|
||||
end
|
||||
|
||||
|
||||
def partial_with_locals
|
||||
render :partial => "customer", :locals => { :customer => Customer.new("david") }
|
||||
render :partial => "customer", :locals => { :customer => Customer.new("david") }
|
||||
end
|
||||
|
||||
def partial_with_form_builder
|
||||
|
@ -151,11 +151,11 @@ class NewRenderTestController < ActionController::Base
|
|||
def partial_collection
|
||||
render :partial => "customer", :collection => [ Customer.new("david"), Customer.new("mary") ]
|
||||
end
|
||||
|
||||
|
||||
def partial_collection_with_spacer
|
||||
render :partial => "customer", :spacer_template => "partial_only", :collection => [ Customer.new("david"), Customer.new("mary") ]
|
||||
end
|
||||
|
||||
|
||||
def partial_collection_with_counter
|
||||
render :partial => "customer_counter", :collection => [ Customer.new("david"), Customer.new("mary") ]
|
||||
end
|
||||
|
@ -186,33 +186,33 @@ class NewRenderTestController < ActionController::Base
|
|||
def empty_partial_collection
|
||||
render :partial => "customer", :collection => []
|
||||
end
|
||||
|
||||
|
||||
def partial_with_hash_object
|
||||
render :partial => "hash_object", :object => {:first_name => "Sam"}
|
||||
end
|
||||
|
||||
|
||||
def partial_hash_collection
|
||||
render :partial => "hash_object", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ]
|
||||
end
|
||||
|
||||
|
||||
def partial_hash_collection_with_locals
|
||||
render :partial => "hash_greeting", :collection => [ {:first_name => "Pratik"}, {:first_name => "Amy"} ], :locals => { :greeting => "Hola" }
|
||||
end
|
||||
|
||||
|
||||
def partial_with_implicit_local_assignment
|
||||
@customer = Customer.new("Marcel")
|
||||
render :partial => "customer"
|
||||
end
|
||||
|
||||
|
||||
def missing_partial
|
||||
render :partial => 'thisFileIsntHere'
|
||||
end
|
||||
|
||||
|
||||
def hello_in_a_string
|
||||
@customers = [ Customer.new("david"), Customer.new("mary") ]
|
||||
render :text => "How's there? " << render_to_string(:template => "test/list")
|
||||
end
|
||||
|
||||
|
||||
def render_to_string_with_assigns
|
||||
@before = "i'm before the render"
|
||||
render_to_string :text => "foo"
|
||||
|
@ -222,14 +222,14 @@ class NewRenderTestController < ActionController::Base
|
|||
|
||||
def render_to_string_with_partial
|
||||
@partial_only = render_to_string :partial => "partial_only"
|
||||
@partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") }
|
||||
render :action => "test/hello_world"
|
||||
end
|
||||
|
||||
@partial_with_locals = render_to_string :partial => "customer", :locals => { :customer => Customer.new("david") }
|
||||
render :action => "test/hello_world"
|
||||
end
|
||||
|
||||
def render_to_string_with_exception
|
||||
render_to_string :file => "exception that will not be caught - this will certainly not work", :use_full_path => true
|
||||
end
|
||||
|
||||
|
||||
def render_to_string_with_caught_exception
|
||||
@before = "i'm before the render"
|
||||
begin
|
||||
|
@ -282,7 +282,7 @@ class NewRenderTestController < ActionController::Base
|
|||
render :text => "hello"
|
||||
redirect_to :action => "double_render"
|
||||
end
|
||||
|
||||
|
||||
def render_to_string_and_render
|
||||
@stuff = render_to_string :text => "here is some cached stuff"
|
||||
render :text => "Hi web users! #{@stuff}"
|
||||
|
@ -329,7 +329,7 @@ class NewRenderTestController < ActionController::Base
|
|||
def render_with_location
|
||||
render :xml => "<hello/>", :location => "http://example.com", :status => 201
|
||||
end
|
||||
|
||||
|
||||
def render_with_object_location
|
||||
customer = Customer.new("Some guy", 1)
|
||||
render :xml => "<customer/>", :location => customer_url(customer), :status => :created
|
||||
|
@ -341,12 +341,12 @@ class NewRenderTestController < ActionController::Base
|
|||
"<i-am-xml/>"
|
||||
end
|
||||
end.new
|
||||
|
||||
|
||||
render :xml => to_xmlable
|
||||
end
|
||||
|
||||
helper NewRenderTestHelper
|
||||
helper do
|
||||
helper do
|
||||
def rjs_helper_method(value)
|
||||
page.visual_effect :highlight, value
|
||||
end
|
||||
|
@ -383,7 +383,7 @@ class NewRenderTestController < ActionController::Base
|
|||
page.visual_effect :highlight, 'balance'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def update_page_with_instance_variables
|
||||
@money = '$37,000,000.00'
|
||||
@div_id = 'balance'
|
||||
|
@ -426,12 +426,12 @@ class NewRenderTestController < ActionController::Base
|
|||
def render_using_layout_around_block_in_main_layout_and_within_content_for_layout
|
||||
render :action => "using_layout_around_block"
|
||||
end
|
||||
|
||||
|
||||
def rescue_action(e) raise end
|
||||
|
||||
|
||||
private
|
||||
def determine_layout
|
||||
case action_name
|
||||
case action_name
|
||||
when "hello_world", "layout_test", "rendering_without_layout",
|
||||
"rendering_nothing_on_layout", "render_text_hello_world",
|
||||
"render_text_hello_world_with_layout",
|
||||
|
@ -443,7 +443,7 @@ class NewRenderTestController < ActionController::Base
|
|||
"render_js_with_explicit_template",
|
||||
"render_js_with_explicit_action_template",
|
||||
"delete_with_js", "update_page", "update_page_with_instance_variables"
|
||||
|
||||
|
||||
"layouts/standard"
|
||||
when "builder_layout_test"
|
||||
"layouts/builder"
|
||||
|
@ -457,8 +457,8 @@ class NewRenderTestController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
NewRenderTestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
Fun::GamesController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
NewRenderTestController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
Fun::GamesController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class NewRenderTest < Test::Unit::TestCase
|
||||
def setup
|
||||
|
@ -527,7 +527,7 @@ class NewRenderTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_render_file_not_using_full_path
|
||||
get :render_file_not_using_full_path
|
||||
get :render_file_not_using_full_path
|
||||
assert_equal "The secret is in the sauce\n", @response.body
|
||||
end
|
||||
|
||||
|
@ -540,7 +540,7 @@ class NewRenderTest < Test::Unit::TestCase
|
|||
get :render_file_with_locals
|
||||
assert_equal "The secret is in the sauce\n", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_render_file_from_template
|
||||
get :render_file_from_template
|
||||
assert_equal "The secret is in the sauce\n", @response.body
|
||||
|
@ -661,7 +661,7 @@ EOS
|
|||
assert_not_deprecated { get :hello_in_a_string }
|
||||
assert_equal "How's there? goodbyeHello: davidHello: marygoodbye\n", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_render_to_string_doesnt_break_assigns
|
||||
get :render_to_string_with_assigns
|
||||
assert_equal "i'm before the render", assigns(:before)
|
||||
|
@ -672,12 +672,12 @@ EOS
|
|||
get :render_to_string_with_partial
|
||||
assert_equal "only partial", assigns(:partial_only)
|
||||
assert_equal "Hello: david", assigns(:partial_with_locals)
|
||||
end
|
||||
end
|
||||
|
||||
def test_bad_render_to_string_still_throws_exception
|
||||
assert_raises(ActionView::MissingTemplate) { get :render_to_string_with_exception }
|
||||
end
|
||||
|
||||
|
||||
def test_render_to_string_that_throws_caught_exception_doesnt_break_assigns
|
||||
assert_nothing_raised { get :render_to_string_with_caught_exception }
|
||||
assert_equal "i'm before the render", assigns(:before)
|
||||
|
@ -715,7 +715,7 @@ EOS
|
|||
def test_render_and_redirect
|
||||
assert_raises(ActionController::DoubleRenderError) { get :render_and_redirect }
|
||||
end
|
||||
|
||||
|
||||
# specify the one exception to double render rule - render_to_string followed by render
|
||||
def test_render_to_string_and_render
|
||||
get :render_to_string_and_render
|
||||
|
@ -736,7 +736,7 @@ EOS
|
|||
get :partials_list
|
||||
assert_equal "goodbyeHello: davidHello: marygoodbye\n", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_partial_with_locals
|
||||
get :partial_with_locals
|
||||
assert_equal "Hello: david", @response.body
|
||||
|
@ -758,17 +758,17 @@ EOS
|
|||
get :partial_collection
|
||||
assert_equal "Hello: davidHello: mary", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_partial_collection_with_counter
|
||||
get :partial_collection_with_counter
|
||||
assert_equal "david0mary1", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_partial_collection_with_locals
|
||||
get :partial_collection_with_locals
|
||||
assert_equal "Bonjour: davidBonjour: mary", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_partial_collection_with_spacer
|
||||
get :partial_collection_with_spacer
|
||||
assert_equal "Hello: davidonly partialHello: mary", @response.body
|
||||
|
@ -793,12 +793,12 @@ EOS
|
|||
get :partial_with_hash_object
|
||||
assert_equal "Sam\nmaS\n", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_hash_partial_collection
|
||||
get :partial_hash_collection
|
||||
assert_equal "Pratik\nkitarP\nAmy\nymA\n", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_partial_hash_collection_with_locals
|
||||
get :partial_hash_collection_with_locals
|
||||
assert_equal "Hola: PratikHola: Amy", @response.body
|
||||
|
@ -808,25 +808,25 @@ EOS
|
|||
get :partial_with_implicit_local_assignment
|
||||
assert_equal "Hello: Marcel", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_render_missing_partial_template
|
||||
assert_raises(ActionView::MissingTemplate) do
|
||||
get :missing_partial
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
def test_render_text_with_assigns
|
||||
get :render_text_with_assigns
|
||||
assert_equal "world", assigns["hello"]
|
||||
end
|
||||
|
||||
|
||||
def test_update_page
|
||||
get :update_page
|
||||
assert_template nil
|
||||
assert_equal 'text/javascript; charset=utf-8', @response.headers['type']
|
||||
assert_equal 2, @response.body.split($/).length
|
||||
end
|
||||
|
||||
|
||||
def test_update_page_with_instance_variables
|
||||
get :update_page_with_instance_variables
|
||||
assert_template nil
|
||||
|
@ -834,7 +834,7 @@ EOS
|
|||
assert_match /balance/, @response.body
|
||||
assert_match /\$37/, @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_yield_content_for
|
||||
assert_not_deprecated { get :yield_content_for }
|
||||
assert_equal "<title>Putting stuff in the title!</title>\n\nGreat stuff!\n", @response.body
|
||||
|
@ -906,12 +906,12 @@ EOS
|
|||
get :render_with_location
|
||||
assert_equal "http://example.com", @response.headers["Location"]
|
||||
end
|
||||
|
||||
|
||||
def test_rendering_xml_should_call_to_xml_if_possible
|
||||
get :render_with_to_xml
|
||||
assert_equal "<i-am-xml/>", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_rendering_with_object_location_should_set_header_with_url_for
|
||||
ActionController::Routing::Routes.draw do |map|
|
||||
map.resources :customers
|
||||
|
@ -941,5 +941,4 @@ EOS
|
|||
get :render_using_layout_around_block_in_main_layout_and_within_content_for_layout
|
||||
assert_equal "Before (Anthony)\nInside from first block in layout\nAfter\nBefore (David)\nInside from block\nAfter\nBefore (Ramm)\nInside from second block in layout\nAfter\n", @response.body
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -23,11 +23,11 @@ class TestController < ActionController::Base
|
|||
def render_hello_world_with_forward_slash
|
||||
render :template => "/test/hello_world"
|
||||
end
|
||||
|
||||
|
||||
def render_template_in_top_directory
|
||||
render :template => 'shared'
|
||||
end
|
||||
|
||||
|
||||
def render_template_in_top_directory_with_slash
|
||||
render :template => '/shared'
|
||||
end
|
||||
|
@ -86,7 +86,7 @@ class TestController < ActionController::Base
|
|||
def render_nothing_with_appendix
|
||||
render :text => "appended"
|
||||
end
|
||||
|
||||
|
||||
def render_invalid_args
|
||||
render("test/hello")
|
||||
end
|
||||
|
@ -171,7 +171,7 @@ class TestController < ActionController::Base
|
|||
def partial_dot_html
|
||||
render :partial => 'partial.html.erb'
|
||||
end
|
||||
|
||||
|
||||
def partial_as_rjs
|
||||
render :update do |page|
|
||||
page.replace :foo, :partial => 'partial'
|
||||
|
@ -217,8 +217,8 @@ class TestController < ActionController::Base
|
|||
end
|
||||
end
|
||||
|
||||
TestController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
Fun::GamesController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
TestController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
Fun::GamesController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class RenderTest < Test::Unit::TestCase
|
||||
def setup
|
||||
|
@ -251,13 +251,13 @@ class RenderTest < Test::Unit::TestCase
|
|||
get :render_hello_world_with_forward_slash
|
||||
assert_template "test/hello_world"
|
||||
end
|
||||
|
||||
|
||||
def test_render_in_top_directory
|
||||
get :render_template_in_top_directory
|
||||
assert_template "shared"
|
||||
assert_equal "Elastica", @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_render_in_top_directory_with_slash
|
||||
get :render_template_in_top_directory_with_slash
|
||||
assert_template "shared"
|
||||
|
@ -336,11 +336,11 @@ class RenderTest < Test::Unit::TestCase
|
|||
assert_response 200
|
||||
assert_equal 'appended', @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_attempt_to_render_with_invalid_arguments
|
||||
assert_raises(ActionController::RenderError) { get :render_invalid_args }
|
||||
end
|
||||
|
||||
|
||||
def test_attempt_to_access_object_method
|
||||
assert_raises(ActionController::UnknownAction, "No action responded to [clone]") { get :clone }
|
||||
end
|
||||
|
@ -467,17 +467,17 @@ class RenderTest < Test::Unit::TestCase
|
|||
get :formatted_html_erb
|
||||
assert_equal 'formatted html erb', @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_should_render_formatted_xml_erb_template
|
||||
get :formatted_xml_erb, :format => :xml
|
||||
assert_equal '<test>passed formatted xml erb</test>', @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_should_render_formatted_html_erb_template
|
||||
get :formatted_xml_erb
|
||||
assert_equal '<test>passed formatted html erb</test>', @response.body
|
||||
end
|
||||
|
||||
|
||||
def test_should_render_formatted_html_erb_template_with_faulty_accepts_header
|
||||
@request.env["HTTP_ACCEPT"] = "image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, appliction/x-shockwave-flash, */*"
|
||||
get :formatted_xml_erb
|
||||
|
@ -520,7 +520,6 @@ class RenderTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
protected
|
||||
|
||||
def etag_for(text)
|
||||
%("#{Digest::MD5.hexdigest(text)}")
|
||||
end
|
||||
|
|
|
@ -1,13 +1,11 @@
|
|||
require 'abstract_unit'
|
||||
|
||||
|
||||
module TestFileUtils
|
||||
def file_name() File.basename(__FILE__) end
|
||||
def file_path() File.expand_path(__FILE__) end
|
||||
def file_data() File.open(file_path, 'rb') { |f| f.read } end
|
||||
end
|
||||
|
||||
|
||||
class SendFileController < ActionController::Base
|
||||
include TestFileUtils
|
||||
layout "layouts/standard" # to make sure layouts don't interfere
|
||||
|
@ -21,7 +19,7 @@ class SendFileController < ActionController::Base
|
|||
def rescue_action(e) raise end
|
||||
end
|
||||
|
||||
SendFileController.view_paths = [ File.dirname(__FILE__) + "/../fixtures/" ]
|
||||
SendFileController.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class SendFileTest < Test::Unit::TestCase
|
||||
include TestFileUtils
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
require 'abstract_unit'
|
||||
|
||||
class ViewLoadPathsTest < Test::Unit::TestCase
|
||||
LOAD_PATH_ROOT = File.join(File.dirname(__FILE__), '..', 'fixtures')
|
||||
|
||||
ActionController::Base.view_paths = [LOAD_PATH_ROOT]
|
||||
ActionController::Base.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
class TestController < ActionController::Base
|
||||
def self.controller_path() "test" end
|
||||
|
@ -16,7 +14,7 @@ class ViewLoadPathsTest < Test::Unit::TestCase
|
|||
|
||||
private
|
||||
def add_view_path
|
||||
prepend_view_path "#{LOAD_PATH_ROOT}/override"
|
||||
prepend_view_path "#{FIXTURE_LOAD_PATH}/override"
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -47,35 +45,35 @@ class ViewLoadPathsTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_template_load_path_was_set_correctly
|
||||
assert_equal [ LOAD_PATH_ROOT ], @controller.view_paths
|
||||
assert_equal [FIXTURE_LOAD_PATH], @controller.view_paths
|
||||
end
|
||||
|
||||
def test_controller_appends_view_path_correctly
|
||||
@controller.append_view_path 'foo'
|
||||
assert_equal [LOAD_PATH_ROOT, 'foo'], @controller.view_paths
|
||||
assert_equal [FIXTURE_LOAD_PATH, 'foo'], @controller.view_paths
|
||||
|
||||
@controller.append_view_path(%w(bar baz))
|
||||
assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths
|
||||
assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz'], @controller.view_paths
|
||||
|
||||
@controller.append_view_path(LOAD_PATH_ROOT)
|
||||
assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths
|
||||
@controller.append_view_path(FIXTURE_LOAD_PATH)
|
||||
assert_equal ['foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths
|
||||
|
||||
@controller.append_view_path([LOAD_PATH_ROOT])
|
||||
assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths
|
||||
@controller.append_view_path([FIXTURE_LOAD_PATH])
|
||||
assert_equal ['foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths
|
||||
end
|
||||
|
||||
def test_controller_prepends_view_path_correctly
|
||||
@controller.prepend_view_path 'baz'
|
||||
assert_equal ['baz', LOAD_PATH_ROOT], @controller.view_paths
|
||||
assert_equal ['baz', FIXTURE_LOAD_PATH], @controller.view_paths
|
||||
|
||||
@controller.prepend_view_path(%w(foo bar))
|
||||
assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths
|
||||
assert_equal ['foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths
|
||||
|
||||
@controller.prepend_view_path(LOAD_PATH_ROOT)
|
||||
assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths
|
||||
@controller.prepend_view_path(FIXTURE_LOAD_PATH)
|
||||
assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz'], @controller.view_paths
|
||||
|
||||
@controller.prepend_view_path([LOAD_PATH_ROOT])
|
||||
assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths
|
||||
@controller.prepend_view_path([FIXTURE_LOAD_PATH])
|
||||
assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz'], @controller.view_paths
|
||||
end
|
||||
|
||||
def test_template_appends_view_path_correctly
|
||||
|
@ -83,10 +81,10 @@ class ViewLoadPathsTest < Test::Unit::TestCase
|
|||
class_view_paths = TestController.view_paths
|
||||
|
||||
@controller.append_view_path 'foo'
|
||||
assert_equal [LOAD_PATH_ROOT, 'foo'], @controller.view_paths
|
||||
assert_equal [FIXTURE_LOAD_PATH, 'foo'], @controller.view_paths
|
||||
|
||||
@controller.append_view_path(%w(bar baz))
|
||||
assert_equal [LOAD_PATH_ROOT, 'foo', 'bar', 'baz'], @controller.view_paths
|
||||
assert_equal [FIXTURE_LOAD_PATH, 'foo', 'bar', 'baz'], @controller.view_paths
|
||||
assert_equal class_view_paths, TestController.view_paths
|
||||
end
|
||||
|
||||
|
@ -95,10 +93,10 @@ class ViewLoadPathsTest < Test::Unit::TestCase
|
|||
class_view_paths = TestController.view_paths
|
||||
|
||||
@controller.prepend_view_path 'baz'
|
||||
assert_equal ['baz', LOAD_PATH_ROOT], @controller.view_paths
|
||||
assert_equal ['baz', FIXTURE_LOAD_PATH], @controller.view_paths
|
||||
|
||||
@controller.prepend_view_path(%w(foo bar))
|
||||
assert_equal ['foo', 'bar', 'baz', LOAD_PATH_ROOT], @controller.view_paths
|
||||
assert_equal ['foo', 'bar', 'baz', FIXTURE_LOAD_PATH], @controller.view_paths
|
||||
assert_equal class_view_paths, TestController.view_paths
|
||||
end
|
||||
|
||||
|
@ -109,7 +107,7 @@ class ViewLoadPathsTest < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_view_paths_override
|
||||
TestController.prepend_view_path "#{LOAD_PATH_ROOT}/override"
|
||||
TestController.prepend_view_path "#{FIXTURE_LOAD_PATH}/override"
|
||||
get :hello_world
|
||||
assert_response :success
|
||||
assert_equal "Hello overridden world!", @response.body
|
||||
|
@ -117,7 +115,7 @@ class ViewLoadPathsTest < Test::Unit::TestCase
|
|||
|
||||
def test_view_paths_override_for_layouts_in_controllers_with_a_module
|
||||
@controller = Test::SubController.new
|
||||
Test::SubController.view_paths = [ "#{LOAD_PATH_ROOT}/override", LOAD_PATH_ROOT, "#{LOAD_PATH_ROOT}/override2" ]
|
||||
Test::SubController.view_paths = [ "#{FIXTURE_LOAD_PATH}/override", FIXTURE_LOAD_PATH, "#{FIXTURE_LOAD_PATH}/override2" ]
|
||||
get :hello_world
|
||||
assert_response :success
|
||||
assert_equal "layout: Hello overridden world!", @response.body
|
||||
|
|
|
@ -2,11 +2,9 @@ require 'abstract_unit'
|
|||
require 'controller/fake_models'
|
||||
|
||||
class ViewRenderTest < Test::Unit::TestCase
|
||||
FIXTURE_LOAD_PATHS = ActionView::ViewLoadPaths.new([File.join(File.dirname(__FILE__), '..', 'fixtures')])
|
||||
|
||||
def setup
|
||||
@assigns = { :secret => 'in the sauce' }
|
||||
@view = ActionView::Base.new(FIXTURE_LOAD_PATHS, @assigns)
|
||||
@view = ActionView::Base.new([FIXTURE_LOAD_PATH], @assigns)
|
||||
end
|
||||
|
||||
def test_render_file
|
||||
|
|
|
@ -301,7 +301,7 @@ end
|
|||
|
||||
class UrlHelperWithControllerTest < ActionView::TestCase
|
||||
class UrlHelperController < ActionController::Base
|
||||
self.view_paths = [ "#{File.dirname(__FILE__)}/../fixtures/" ]
|
||||
self.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
def self.controller_path; 'url_helper_with_controller' end
|
||||
|
||||
|
@ -356,7 +356,7 @@ end
|
|||
|
||||
class LinkToUnlessCurrentWithControllerTest < ActionView::TestCase
|
||||
class TasksController < ActionController::Base
|
||||
self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
|
||||
self.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
def self.controller_path; 'tasks' end
|
||||
|
||||
|
@ -448,7 +448,7 @@ end
|
|||
|
||||
class PolymorphicControllerTest < ActionView::TestCase
|
||||
class WorkshopsController < ActionController::Base
|
||||
self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
|
||||
self.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
def self.controller_path; 'workshops' end
|
||||
|
||||
|
@ -466,7 +466,7 @@ class PolymorphicControllerTest < ActionView::TestCase
|
|||
end
|
||||
|
||||
class SessionsController < ActionController::Base
|
||||
self.view_paths = ["#{File.dirname(__FILE__)}/../fixtures/"]
|
||||
self.view_paths = [FIXTURE_LOAD_PATH]
|
||||
|
||||
def self.controller_path; 'sessions' end
|
||||
|
||||
|
|
Loading…
Reference in a new issue