Permalink
Browse files

Merge branch 'master' of git@github.com:lifo/docrails

  • Loading branch information...
2 parents 5469a0b + 1b32f88 commit 7a17ad3f2b89baea94450af8e63a640ace570938 @aditya aditya committed May 2, 2009
Showing with 2,041 additions and 6,371 deletions.
  1. +6 −5 actionmailer/lib/action_mailer/base.rb
  2. +2 −2 actionmailer/test/mail_service_test.rb
  3. +23 −21 actionpack/lib/action_controller/base/base.rb
  4. +1 −1 actionpack/lib/action_controller/base/mime_responds.rb
  5. +5 −4 actionpack/lib/action_controller/base/render.rb
  6. +1 −1 actionpack/lib/action_controller/caching/actions.rb
  7. +0 −1 actionpack/lib/action_controller/dispatch/middlewares.rb
  8. +1 −1 actionpack/lib/action_controller/routing.rb
  9. +22 −10 actionpack/lib/action_controller/testing/assertions/response.rb
  10. +30 −158 actionpack/lib/action_controller/testing/integration.rb
  11. +22 −162 actionpack/lib/action_controller/testing/process.rb
  12. +7 −8 actionpack/lib/action_dispatch.rb
  13. +10 −14 actionpack/lib/action_dispatch/http/request.rb
  14. +97 −8 actionpack/lib/action_dispatch/http/response.rb
  15. +3 −3 actionpack/lib/action_dispatch/middleware/failsafe.rb
  16. +0 −19 actionpack/lib/action_dispatch/middleware/rewindable_input.rb
  17. +26 −4 actionpack/lib/action_dispatch/middleware/session/abstract_store.rb
  18. +4 −3 actionpack/lib/action_dispatch/middleware/session/cookie_store.rb
  19. +115 −0 actionpack/lib/action_dispatch/test/mock.rb
  20. +33 −0 actionpack/lib/action_dispatch/test/uploaded_file.rb
  21. +0 −89 actionpack/lib/action_dispatch/vendor/rack-1.0/rack.rb
  22. +0 −22 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/adapter/camping.rb
  23. +0 −37 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/auth/abstract/handler.rb
  24. +0 −37 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/auth/abstract/request.rb
  25. +0 −58 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/auth/basic.rb
  26. +0 −124 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/auth/digest/md5.rb
  27. +0 −51 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/auth/digest/nonce.rb
  28. +0 −55 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/auth/digest/params.rb
  29. +0 −40 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/auth/digest/request.rb
  30. +0 −480 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/auth/openid.rb
  31. +0 −63 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/builder.rb
  32. +0 −36 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/cascade.rb
  33. +0 −49 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/chunked.rb
  34. +0 −61 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/commonlogger.rb
  35. +0 −45 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/conditionalget.rb
  36. +0 −29 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/content_length.rb
  37. +0 −23 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/content_type.rb
  38. +0 −85 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/deflater.rb
  39. +0 −153 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/directory.rb
  40. +0 −88 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/file.rb
  41. +0 −48 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler.rb
  42. +0 −61 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler/cgi.rb
  43. +0 −8 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler/evented_mongrel.rb
  44. +0 −89 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler/fastcgi.rb
  45. +0 −55 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler/lsws.rb
  46. +0 −84 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler/mongrel.rb
  47. +0 −59 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler/scgi.rb
  48. +0 −8 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler/swiftiplied_mongrel.rb
  49. +0 −18 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler/thin.rb
  50. +0 −67 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/handler/webrick.rb
  51. +0 −19 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/head.rb
  52. +0 −462 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/lint.rb
  53. +0 −65 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/lobster.rb
  54. +0 −16 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/lock.rb
  55. +0 −27 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/methodoverride.rb
  56. +0 −204 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/mime.rb
  57. +0 −160 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/mock.rb
  58. +0 −57 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/recursive.rb
  59. +0 −64 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/reloader.rb
  60. +0 −241 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/request.rb
  61. +0 −179 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/response.rb
  62. +0 −142 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/session/abstract/id.rb
  63. +0 −91 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/session/cookie.rb
  64. +0 −109 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/session/memcache.rb
  65. +0 −100 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/session/pool.rb
  66. +0 −349 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/showexceptions.rb
  67. +0 −106 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/showstatus.rb
  68. +0 −38 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/static.rb
  69. +0 −55 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/urlmap.rb
  70. +0 −392 actionpack/lib/action_dispatch/vendor/rack-1.0/rack/utils.rb
  71. +4 −2 actionpack/lib/action_view/base.rb
  72. +9 −11 actionpack/lib/action_view/helpers/prototype_helper.rb
  73. +6 −6 actionpack/lib/action_view/paths.rb
  74. +7 −6 actionpack/lib/action_view/render/rendering.rb
  75. +2 −2 actionpack/lib/action_view/template/error.rb
  76. +1 −1 actionpack/lib/action_view/template/handlers.rb
  77. +45 −23 actionpack/lib/action_view/template/path.rb
  78. +54 −162 actionpack/lib/action_view/template/template.rb
  79. +7 −5 actionpack/lib/action_view/test_case.rb
  80. +1 −1 actionpack/test/abstract_controller/abstract_controller_test.rb
  81. +1 −0 actionpack/test/activerecord/active_record_store_test.rb
  82. +12 −10 actionpack/test/controller/action_pack_assertions_test.rb
  83. +1 −1 actionpack/test/controller/dispatcher_test.rb
  84. +107 −70 actionpack/test/controller/filters_test.rb
  85. +24 −24 actionpack/test/controller/flash_test.rb
  86. +1 −1 actionpack/test/controller/helper_test.rb
  87. +0 −2 actionpack/test/controller/http_digest_authentication_test.rb
  88. +2 −2 actionpack/test/controller/integration_test.rb
  89. +18 −16 actionpack/test/controller/layout_test.rb
  90. +4 −3 actionpack/test/controller/render_test.rb
  91. +12 −11 actionpack/test/controller/request/test_request_test.rb
  92. +0 −6 actionpack/test/controller/test_test.rb
  93. +29 −20 actionpack/test/controller/view_paths_test.rb
  94. +0 −90 actionpack/test/dispatch/rack_test.rb
  95. +1 −63 actionpack/test/dispatch/request/multipart_params_parsing_test.rb
  96. +0 −38 actionpack/test/dispatch/request/url_encoded_params_parsing_test.rb
  97. +130 −0 actionpack/test/dispatch/response_test.rb
  98. +1 −2 actionpack/test/dispatch/session/cookie_store_test.rb
  99. +8 −16 actionpack/test/dispatch/session/test_session_test.rb
  100. 0 actionpack/test/fixtures/layouts/{standard.erb → standard.html.erb}
  101. +1 −0 actionpack/test/fixtures/test/render_file_with_locals_and_default.erb
  102. +1 −1 actionpack/test/template/body_parts_test.rb
  103. +5 −31 actionpack/test/template/compiled_templates_test.rb
  104. +9 −9 actionpack/test/template/output_buffer_test.rb
  105. +3 −11 actionpack/test/template/render_test.rb
  106. +9 −5 activerecord/lib/active_record/autosave_association.rb
  107. +1 −1 activerecord/lib/active_record/base.rb
  108. +4 −4 activerecord/lib/active_record/serialization.rb
  109. +6 −3 activerecord/lib/active_record/serializers/json_serializer.rb
  110. +1 −1 activerecord/lib/active_record/test_case.rb
  111. +5 −5 activerecord/test/cases/associations/eager_load_nested_include_test.rb
  112. +22 −0 activerecord/test/cases/autosave_association_test.rb
  113. +3 −3 activerecord/test/cases/base_test.rb
  114. +1 −1 activerecord/test/cases/calculations_test.rb
  115. +4 −4 activerecord/test/cases/finder_test.rb
  116. +1 −1 activerecord/test/cases/method_scoping_test.rb
  117. +5 −3 activeresource/lib/active_resource/base.rb
  118. +2 −2 activesupport/lib/active_support/core_ext/integer/even_odd.rb
  119. +3 −1 activesupport/lib/active_support/core_ext/module/delegation.rb
  120. +1 −1 activesupport/lib/active_support/core_ext/string/conversions.rb
  121. +2 −2 activesupport/lib/active_support/core_ext/time/conversions.rb
  122. +1 −1 activesupport/lib/active_support/deprecation/proxy_wrappers.rb
  123. +33 −6 activesupport/lib/active_support/json.rb
  124. +19 −20 activesupport/lib/active_support/json/encoders/date.rb
  125. +19 −20 activesupport/lib/active_support/json/encoders/date_time.rb
  126. +11 −12 activesupport/lib/active_support/json/encoders/enumerable.rb
  127. +4 −5 activesupport/lib/active_support/json/encoders/false_class.rb
  128. +45 −44 activesupport/lib/active_support/json/encoders/hash.rb
  129. +4 −5 activesupport/lib/active_support/json/encoders/nil_class.rb
  130. +4 −5 activesupport/lib/active_support/json/encoders/numeric.rb
  131. +6 −3 activesupport/lib/active_support/json/encoders/object.rb
  132. +4 −5 activesupport/lib/active_support/json/encoders/regexp.rb
  133. +4 −36 activesupport/lib/active_support/json/encoders/string.rb
  134. +4 −5 activesupport/lib/active_support/json/encoders/symbol.rb
  135. +19 −20 activesupport/lib/active_support/json/encoders/time.rb
  136. +4 −5 activesupport/lib/active_support/json/encoders/true_class.rb
  137. +6 −4 activesupport/lib/active_support/json/encoding.rb
  138. +4 −3 activesupport/lib/active_support/json/variable.rb
  139. +20 −22 activesupport/lib/active_support/time_with_zone.rb
  140. +162 −0 activesupport/lib/active_support/xml_mini/jdom.rb
  141. +10 −10 activesupport/test/core_ext/duration_test.rb
  142. +4 −4 activesupport/test/core_ext/time_ext_test.rb
  143. +1 −1 activesupport/test/core_ext/time_with_zone_test.rb
  144. +1 −1 activesupport/test/json/encoding_test.rb
  145. +153 −0 activesupport/test/xml_mini/jdom_engine_test.rb
  146. +1 −1 ci/geminstaller.yml
  147. +1 −1 railties/guides/source/credits.erb.textile
  148. +1 −1 railties/guides/source/layouts_and_rendering.textile
  149. +226 −6 railties/guides/source/rails_application_templates.textile
  150. +1 −1 railties/guides/source/security.textile
  151. +0 −1 railties/lib/commands/server.rb
  152. +2 −0 railties/lib/console_app.rb
  153. +29 −4 railties/lib/initializer.rb
  154. +3 −0 railties/lib/rails/backtrace_cleaner.rb
  155. +17 −4 railties/lib/rails/gem_dependency.rb
  156. +0 −3 railties/lib/rails/plugin.rb
  157. +16 −2 railties/lib/tasks/gems.rake
  158. +5 −1 railties/lib/tasks/misc.rake
  159. +1 −0 railties/test/abstract_unit.rb
  160. +1 −0 railties/test/boot_test.rb
  161. +43 −0 railties/test/gem_dependency_test.rb
  162. +2 −2 railties/test/plugin_loader_test.rb
  163. +2 −1 railties/test/plugin_test_helper.rb
  164. +29 −0 railties/test/vendor/gems/dummy-gem-h-1.0.0/.specification
  165. +1 −0 railties/test/vendor/gems/dummy-gem-h-1.0.0/lib/dummy-gem-h.rb
  166. +41 −0 railties/test/vendor/gems/dummy-gem-i-1.0.0/.specification
  167. 0 railties/test/vendor/gems/dummy-gem-i-1.0.0/ext/dummy-gem-i/Makefile
  168. +1 −0 railties/test/vendor/gems/dummy-gem-i-1.0.0/lib/dummy-gem-i.rb
  169. +41 −0 railties/test/vendor/gems/dummy-gem-j-1.0.0/.specification
  170. +1 −0 railties/test/vendor/gems/dummy-gem-j-1.0.0/lib/dummy-gem-j.rb
  171. +49 −0 railties/test/vendor/gems/dummy-gem-k-1.0.0/.specification
  172. +1 −0 railties/test/vendor/gems/dummy-gem-k-1.0.0/lib/dummy-gem-k.rb
@@ -475,7 +475,7 @@ def create!(method_name, *parameters) #:nodoc:
# if @parts.empty?
template_root.find_all_by_parts(@template, {}, template_path).each do |template|
@parts << Part.new(
- :content_type => Mime::Type.lookup_by_extension(template.content_type || "text").to_s,
+ :content_type => template.mime_type ? template.mime_type.to_s : "text/plain",
:disposition => "inline",
:charset => charset,
:body => render_template(template, @body)
@@ -555,12 +555,13 @@ def initialize_defaults(method_name)
end
def render_template(template, body)
- if template.respond_to?(:content_type)
- @current_template_content_type = template.content_type
+ if template.respond_to?(:mime_type)
+ @current_template_content_type = template.mime_type && template.mime_type.to_sym.to_s
end
@template = initialize_template_class(body)
- layout = _pick_layout(layout, true) unless template.exempt_from_layout?
+ layout = _pick_layout(layout, true) unless
+ ActionController::Base.exempt_from_layout.include?(template.handler)
@template._render_template_with_layout(template, layout, {})
ensure
@current_template_content_type = nil
@@ -584,7 +585,7 @@ def render(opts)
end
layout = _pick_layout(layout,
- !template || !template.exempt_from_layout?)
+ !template || ActionController::Base.exempt_from_layout.include?(template.handler))
if template
@template._render_template_with_layout(template, layout, opts)
@@ -994,13 +994,13 @@ def test_starttls_is_not_enabled
class InheritableTemplateRootTest < Test::Unit::TestCase
def test_attr
- expected = "#{File.dirname(__FILE__)}/fixtures/path.with.dots"
+ expected = File.expand_path("#{File.dirname(__FILE__)}/fixtures/path.with.dots")
assert_equal expected, FunkyPathMailer.template_root.to_s
sub = Class.new(FunkyPathMailer)
sub.template_root = 'test/path'
- assert_equal 'test/path', sub.template_root.to_s
+ assert_equal File.expand_path('test/path'), sub.template_root.to_s
assert_equal expected, FunkyPathMailer.template_root.to_s
end
end
@@ -238,7 +238,7 @@ class Base
cattr_reader :protected_instance_variables
# Controller specific instance variables which will not be accessible inside views.
@@protected_instance_variables = %w(@assigns @performed_redirect @performed_render @variables_added @request_origin @url @parent_controller
- @action_name @before_filter_chain_aborted @action_cache_path @_session @_headers @_params
+ @action_name @before_filter_chain_aborted @action_cache_path @_headers @_params
@_flash @_response)
# Prepends all the URL-generating helpers from AssetHelper. This makes it possible to easily move javascripts, stylesheets,
@@ -356,7 +356,9 @@ class Base
# Holds a hash of objects in the session. Accessed like <tt>session[:person]</tt> to get the object tied to the "person"
# key. The session will hold any type of object as values, but the key should be a string or symbol.
- attr_internal :session
+ def session
+ request.session
+ end
# Holds a hash of header names and values. Accessed like <tt>headers["Cache-Control"]</tt> to get the value of the Cache-Control
# directive. Values should always be specified as strings.
@@ -365,6 +367,8 @@ class Base
# Returns the name of the action this controller is processing.
attr_accessor :action_name
+ attr_reader :template
+
class << self
def call(env)
# HACK: For global rescue to have access to the original request and response
@@ -492,8 +496,18 @@ def filter_parameter_logging(*filter_words, &block)
end
protected :filter_parameters
end
+
+ @@exempt_from_layout = [ActionView::TemplateHandlers::RJS]
+
+ def exempt_from_layout(*types)
+ types.each do |type|
+ @@exempt_from_layout <<
+ ActionView::Template.handler_class_for_extension(type)
+ end
+
+ @@exempt_from_layout
+ end
- delegate :exempt_from_layout, :to => 'ActionView::Template'
end
public
@@ -787,7 +801,6 @@ def expires_now #:doc:
# Resets the session by clearing out all the objects stored within and initializing a new session object.
def reset_session #:doc:
request.reset_session
- @_session = request.session
end
private
@@ -805,19 +818,13 @@ def _process_options(options)
def initialize_template_class(response)
@template = response.template = ActionView::Base.new(self.class.view_paths, {}, self, formats)
- response.template.helpers.send :include, self.class.master_helper_module
+ @template.helpers.send :include, self.class.master_helper_module
response.redirected_to = nil
@performed_render = @performed_redirect = false
end
def assign_shortcuts(request, response)
- @_request, @_params = request, request.parameters
-
- @_response = response
- @_response.session = request.session
-
- @_session = @_response.session
-
+ @_request, @_response, @_params = request, response, request.parameters
@_headers = @_response.headers
end
@@ -861,13 +868,13 @@ def perform_action
return (performed? ? ret : default_render) if called
begin
- default_render
- rescue ActionView::MissingTemplate => e
- raise e unless e.action_name == action_name
- # If the path is the same as the action_name, the action is completely missing
+ view_paths.find_by_parts(action_name, {:formats => formats, :locales => [I18n.locale]}, controller_path)
+ rescue => e
raise UnknownAction, "No action responded to #{action_name}. Actions: " +
"#{action_methods.sort.to_sentence}", caller
end
+
+ default_render
end
# Returns true if a render or redirect has already been performed.
@@ -894,10 +901,6 @@ def complete_request_uri
"#{request.protocol}#{request.host}#{request.request_uri}"
end
- def close_session
- # @_session.close if @_session && @_session.respond_to?(:close)
- end
-
def default_template(action_name = self.action_name)
self.view_paths.find_template(default_template_name(action_name), default_template_format)
end
@@ -921,7 +924,6 @@ def template_path_includes_controller?(path)
end
def process_cleanup
- close_session
end
end
@@ -139,7 +139,7 @@ def custom(mime_type, &block)
@order << mime_type
@responses[mime_type] ||= Proc.new do
- @response.template.formats = [mime_type.to_sym]
+ @controller.template.formats = [mime_type.to_sym]
@response.content_type = mime_type.to_s
block_given? ? block.call : @controller.send(:render, :action => @controller.action_name)
end
@@ -254,7 +254,7 @@ def render(options = nil, extra_options = {}, &block) #:doc:
render_for_text(js)
elsif json = options[:json]
- json = ActiveSupport::JSON.encode(json) unless json.is_a?(String)
+ json = ActiveSupport::JSON.encode(json) unless json.respond_to?(:to_str)
json = "#{options[:callback]}(#{json})" unless options[:callback].blank?
response.content_type ||= Mime::JSON
render_for_text(json)
@@ -378,13 +378,14 @@ def render_for_name(name, layout, options)
# ==== Arguments
# parts<Array[String, Array[Symbol*], String, Boolean]>::
# Example: ["show", [:html, :xml], "users", false]
- def render_for_parts(parts, layout, options = {})
+ def render_for_parts(parts, layout_details, options = {})
parts[1] = {:formats => parts[1], :locales => [I18n.locale]}
tmp = view_paths.find_by_parts(*parts)
- layout = _pick_layout(*layout) unless tmp.exempt_from_layout?
-
+ layout = _pick_layout(*layout_details) unless
+ self.class.exempt_from_layout.include?(tmp.handler)
+
render_for_text(
@template._render_template_with_layout(tmp, layout, options, parts[3]))
end
@@ -121,7 +121,7 @@ def cache_layout?
end
def content_for_layout(controller)
- controller.response.layout && controller.response.template.instance_variable_get('@cached_content_for_layout')
+ controller.template.layout && controller.template.instance_variable_get('@cached_content_for_layout')
end
end
@@ -7,7 +7,6 @@
use lambda { ActionController::Base.session_store },
lambda { ActionController::Base.session_options }
-use "ActionDispatch::RewindableInput"
use "ActionDispatch::ParamsParser"
use "Rack::MethodOverride"
use "Rack::Head"
@@ -135,7 +135,7 @@ module ActionController
# # In routes.rb
# map.with_options :controller => 'blog' do |blog|
# blog.show '', :action => 'list'
- # blog.delete 'delete/:id', :action => 'delete',
+ # blog.delete 'delete/:id', :action => 'delete'
# blog.edit 'edit/:id', :action => 'edit'
# end
#
@@ -22,6 +22,8 @@ module ResponseAssertions
# assert_response 401
#
def assert_response(type, message = nil)
+ validate_request!
+
clean_backtrace do
if [ :success, :missing, :redirect, :error ].include?(type) && @response.send("#{type}?")
assert_block("") { true } # to count the assertion
@@ -30,8 +32,8 @@ def assert_response(type, message = nil)
elsif type.is_a?(Symbol) && @response.response_code == ActionDispatch::StatusCodes::SYMBOL_TO_STATUS_CODE[type]
assert_block("") { true } # to count the assertion
else
- if @response.error?
- exception = @response.template.instance_variable_get(:@exception)
+ if @controller && @response.error?
+ exception = @controller.template.instance_variable_get(:@exception)
exception_message = exception && exception.message
assert_block(build_message(message, "Expected response to be a <?>, but was <?>\n<?>", type, @response.response_code, exception_message.to_s)) { false }
else
@@ -57,6 +59,8 @@ def assert_response(type, message = nil)
# assert_redirected_to @customer
#
def assert_redirected_to(options = {}, message=nil)
+ validate_request!
+
clean_backtrace do
assert_response(:redirect, message)
return true if options == @response.redirected_to
@@ -89,25 +93,27 @@ def assert_redirected_to(options = {}, message=nil)
# assert_template :partial => false
#
def assert_template(options = {}, message = nil)
+ validate_request!
+
clean_backtrace do
case options
when NilClass, String
- rendered = @response.rendered[:template].to_s
+ rendered = (@controller.template.rendered[:template] || []).map { |t| t.identifier }
msg = build_message(message,
"expecting <?> but rendering with <?>",
- options, rendered)
+ options, rendered.join(', '))
assert_block(msg) do
if options.nil?
- @response.rendered[:template].blank?
+ @controller.template.rendered[:template].blank?
else
- rendered.to_s.match(options)
+ rendered.any? { |t| t.match(options) }
end
end
when Hash
if expected_partial = options[:partial]
- partials = @response.rendered[:partials]
+ partials = @controller.template.rendered[:partials]
if expected_count = options[:count]
- found = partials.detect { |p, _| p.to_s.match(expected_partial) }
+ found = partials.detect { |p, _| p.identifier.match(expected_partial) }
actual_count = found.nil? ? 0 : found.second
msg = build_message(message,
"expecting ? to be rendered ? time(s) but rendered ? time(s)",
@@ -117,10 +123,10 @@ def assert_template(options = {}, message = nil)
msg = build_message(message,
"expecting partial <?> but action rendered <?>",
options[:partial], partials.keys)
- assert(partials.keys.any? { |p| p.to_s.match(expected_partial) }, msg)
+ assert(partials.keys.any? { |p| p.identifier.match(expected_partial) }, msg)
end
else
- assert @response.rendered[:partials].empty?,
+ assert @controller.template.rendered[:partials].empty?,
"Expected no partials to be rendered"
end
end
@@ -145,6 +151,12 @@ def normalize_argument_to_redirection(fragment)
@request.protocol + @request.host_with_port + after_routing
end
end
+
+ def validate_request!
+ unless @request.is_a?(ActionDispatch::Request)
+ raise ArgumentError, "@request must be an ActionDispatch::Request"
+ end
+ end
end
end
end
Oops, something went wrong.

0 comments on commit 7a17ad3

Please sign in to comment.