Permalink
Browse files

Get controller/layout_test.rb running on new base except for ActionCo…

…ntroller::Base.exempt_from_layout which is going to be deprecated.
  • Loading branch information...
1 parent 0112953 commit 72a574b5073b1debd58c954b34c54d3bdee7749f Yehuda Katz + Carl Lerche committed May 22, 2009
View
@@ -61,12 +61,13 @@ Rake::TestTask.new(:test_new_base_on_old_tests) do |t|
# layout
# Dir.glob( "test/{dispatch,template}/**/*_test.rb" ).sort +
t.test_files = %w(
- addresses_render base benchmark caching capture content_type dispatcher
- flash mime_responds record_identifier redirect
- render render_json render_xml
- send_file request_forgery_protection rescue url_rewriter verification webservice
- http_basic_authentication http_digest_authentication
- action_pack_assertions assert_select filter_params helper
+ action_pack_assertions addresses_render assert_select
+ base benchmark caching capture content_type dispatcher
+ filter_params flash helper http_basic_authentication
+ http_digest_authentication layout mime_responds
+ record_identifier redirect render render_json render_xml
+ send_file request_forgery_protection rescue url_rewriter
+ verification webservice
).map { |name| "test/controller/#{name}_test.rb" }
end
@@ -65,20 +65,20 @@ def _layout() end # This will be overwritten
# :api: plugin
# ====
# Override this to mutate the inbound layout name
- def _layout_for_name(name)
+ def _layout_for_name(name, details = {:formats => formats})
unless [String, FalseClass, NilClass].include?(name.class)
raise ArgumentError, "String, false, or nil expected; you passed #{name.inspect}"
end
- name && view_paths.find_by_parts(name, {:formats => formats}, _layout_prefix(name))
+ name && view_paths.find_by_parts(name, details, _layout_prefix(name))
end
# TODO: Decide if this is the best hook point for the feature
def _layout_prefix(name)
"layouts"
end
- def _default_layout(require_layout = false)
+ def _default_layout(require_layout = false, details = {:formats => formats})
if require_layout && _action_has_layout? && !_layout
raise ArgumentError,
"There was no default layout for #{self.class} in #{view_paths.inspect}"
@@ -11,23 +11,20 @@ def _implied_layout_name
end
end
- def render_to_body(options)
- # render :text => ..., :layout => ...
- # or
- # render :anything_else
+ private
+
+ def _determine_template(options)
+ super
if (!options.key?(:text) && !options.key?(:inline) && !options.key?(:partial)) || options.key?(:layout)
- options[:_layout] = options.key?(:layout) ? _layout_for_option(options[:layout]) : _default_layout
+ options[:_layout] = _layout_for_option(options.key?(:layout) ? options[:layout] : :none, options[:_template].details)
end
-
- super
end
-
- private
- def _layout_for_option(name)
+ def _layout_for_option(name, details)
case name
- when String then _layout_for_name(name)
- when true then _default_layout(true)
+ when String then _layout_for_name(name, details)
+ when true then _default_layout(true, details)
+ when :none then _default_layout(false, details)
when false, nil then nil
else
raise ArgumentError,
@@ -7,7 +7,7 @@
module ActionView
class Template
extend TemplateHandlers
- attr_reader :source, :identifier, :handler, :mime_type
+ attr_reader :source, :identifier, :handler, :mime_type, :details
def initialize(source, identifier, handler, details)
@source = source
@@ -6,6 +6,10 @@ def initialize(string, content_type = Mime[:html])
@content_type = Mime[content_type]
end
+ def details
+ {:formats => [@content_type.to_sym]}
+ end
+
def identifier() self end
def render(*) self end
@@ -174,15 +174,18 @@ def test_layout_is_not_set_when_none_rendered
assert_nil @controller.template.layout
end
- def test_exempt_from_layout_honored_by_render_template
- ActionController::Base.exempt_from_layout :erb
- @controller = RenderWithTemplateOptionController.new
+ for_tag(:old_base) do
+ # exempt_from_layout is deprecated
+ def test_exempt_from_layout_honored_by_render_template
+ ActionController::Base.exempt_from_layout :erb
+ @controller = RenderWithTemplateOptionController.new
- get :hello
- assert_equal "alt/hello.rhtml", @response.body.strip
+ get :hello
+ assert_equal "alt/hello.rhtml", @response.body.strip
- ensure
- ActionController::Base.exempt_from_layout.delete(ERB)
+ ensure
+ ActionController::Base.exempt_from_layout.delete(ERB)
+ end
end
def test_layout_is_picked_from_the_controller_instances_view_path

0 comments on commit 72a574b

Please sign in to comment.