Module: ActionDispatch::TestResponse::DeprecatedHelpers

Included in:
ActionDispatch::TestResponse
Defined in:
lib/action_dispatch/testing/test_response.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#templateObject



18
19
20
21
# File 'lib/action_dispatch/testing/test_response.rb', line 18

def template
  ActiveSupport::Deprecation.warn("response.template has been deprecated. Use controller.template instead", caller)
  @template
end

Instance Method Details

#assignsObject



29
30
31
32
# File 'lib/action_dispatch/testing/test_response.rb', line 29

def assigns
  ActiveSupport::Deprecation.warn("response.assigns has been deprecated. Use controller.assigns instead", caller)
  @template.controller.assigns
end

#binary_contentObject

Returns binary content (downloadable file), converted to a String



103
104
105
106
# File 'lib/action_dispatch/testing/test_response.rb', line 103

def binary_content
  ActiveSupport::Deprecation.warn("response.binary_content has been deprecated. Use response.body instead", caller)
  body
end

#flashObject

A shortcut to the flash. Returns an empty hash if no session flash exists.



61
62
63
64
# File 'lib/action_dispatch/testing/test_response.rb', line 61

def flash
  ActiveSupport::Deprecation.warn("response.flash has been deprecated. Use request.flash instead", caller)
  request.session['flash'] || {}
end

#has_flash?Boolean

Do we have a flash?

Returns:

  • (Boolean)


67
68
69
70
# File 'lib/action_dispatch/testing/test_response.rb', line 67

def has_flash?
  ActiveSupport::Deprecation.warn("response.has_flash? has been deprecated. Use flash.any? instead", caller)
  !flash.empty?
end

#has_flash_object?(name = nil) ⇒ Boolean

Does the specified flash object exist?

Returns:

  • (Boolean)


79
80
81
82
# File 'lib/action_dispatch/testing/test_response.rb', line 79

def has_flash_object?(name=nil)
  ActiveSupport::Deprecation.warn("response.has_flash_object? has been deprecated. Use flash[name] instead", caller)
  !flash[name].nil?
end

#has_flash_with_contents?Boolean

Do we have a flash that has contents?

Returns:

  • (Boolean)


73
74
75
76
# File 'lib/action_dispatch/testing/test_response.rb', line 73

def has_flash_with_contents?
  ActiveSupport::Deprecation.warn("response.has_flash_with_contents? has been deprecated. Use flash.any? instead", caller)
  !flash.empty?
end

#has_session_object?(name = nil) ⇒ Boolean

Does the specified object exist in the session?

Returns:

  • (Boolean)


85
86
87
88
# File 'lib/action_dispatch/testing/test_response.rb', line 85

def has_session_object?(name=nil)
  ActiveSupport::Deprecation.warn("response.has_session_object? has been deprecated. Use session[name] instead", caller)
  !session[name].nil?
end

#has_template_object?(name = nil) ⇒ Boolean

Does the specified template object exist?

Returns:

  • (Boolean)


97
98
99
100
# File 'lib/action_dispatch/testing/test_response.rb', line 97

def has_template_object?(name=nil)
  ActiveSupport::Deprecation.warn("response.has_template_object? has been deprecated. Use tempate.assigns[name].nil? instead", caller)
  !template_objects[name].nil?
end

#layoutObject



34
35
36
37
# File 'lib/action_dispatch/testing/test_response.rb', line 34

def layout
  ActiveSupport::Deprecation.warn("response.layout has been deprecated. Use template.layout instead", caller)
  @template.layout
end

#redirect_url_match?(pattern) ⇒ Boolean

Returns:

  • (Boolean)


44
45
46
47
48
49
50
51
# File 'lib/action_dispatch/testing/test_response.rb', line 44

def redirect_url_match?(pattern)
  ::ActiveSupport::Deprecation.warn("response.redirect_url_match? is deprecated. Use assert_match(/foo/, response.redirect_url) instead", caller)
  return false if redirect_url.nil?
  p = Regexp.new(pattern) if pattern.class == String
  p = pattern if pattern.class == Regexp
  return false if p.nil?
  p.match(redirect_url) != nil
end

#redirected_toObject



39
40
41
42
# File 'lib/action_dispatch/testing/test_response.rb', line 39

def redirected_to
  ::ActiveSupport::Deprecation.warn("response.redirected_to is deprecated. Use response.redirect_url instead", caller)
  redirect_url
end

#renderedObject

Returns the template of the file which was used to render this response (or nil)



55
56
57
58
# File 'lib/action_dispatch/testing/test_response.rb', line 55

def rendered
  ActiveSupport::Deprecation.warn("response.rendered has been deprecated. Use template.rendered instead", caller)
  @template.instance_variable_get(:@_rendered)
end

#sessionObject



24
25
26
27
# File 'lib/action_dispatch/testing/test_response.rb', line 24

def session
  ActiveSupport::Deprecation.warn("response.session has been deprecated. Use request.session instead", caller)
  @request.session
end

#template_objectsObject

A shortcut to the template.assigns



91
92
93
94
# File 'lib/action_dispatch/testing/test_response.rb', line 91

def template_objects
  ActiveSupport::Deprecation.warn("response.template_objects has been deprecated. Use template.assigns instead", caller)
  @template.assigns || {}
end