Class: RespondToFunctionalTest
- Inherits:
-
ActionController::TestCase
- Object
- ActionController::TestCase
- RespondToFunctionalTest
- Defined in:
- lib/vendor/plugins/inherited_resources/test/respond_to_test.rb
Instance Method Summary collapse
- #test_respond_to_all ⇒ Object
- #test_respond_to_first_configured_mime_in_respond_to_when_mime_type_is_all ⇒ Object
- #test_respond_to_overwrite_class_method_definition ⇒ Object
- #test_respond_to_skip_default_template_when_it_is_in_block ⇒ Object
- #test_respond_to_when_a_resource_is_given_as_option ⇒ Object
- #test_respond_with_calls_to_format_on_resource ⇒ Object
- #test_respond_with_forwads_extra_options_to_render ⇒ Object
- #test_respond_with_inherits_format ⇒ Object
- #test_respond_with_layout_rendering ⇒ Object
- #test_respond_with_raises_error_if_could_not_respond ⇒ Object
- #test_respond_with_renders_status_not_acceptable_if_mime_type_is_not_registered ⇒ Object
- #test_respond_with_sets_content_type_properly ⇒ Object
Instance Method Details
#test_respond_to_all ⇒ Object
92 93 94 95 96 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 92 def test_respond_to_all @request.accept = '*/*' get :index assert_equal 'Index HTML', @response.body.strip end |
#test_respond_to_first_configured_mime_in_respond_to_when_mime_type_is_all ⇒ Object
142 143 144 145 146 147 148 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 142 def test_respond_to_first_configured_mime_in_respond_to_when_mime_type_is_all @request.accept = '*/*' assert_raise ActionView::MissingTemplate do get :respond_with_resource_and_blocks end assert_equal 'text/html', @response.content_type end |
#test_respond_to_overwrite_class_method_definition ⇒ Object
136 137 138 139 140 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 136 def test_respond_to_overwrite_class_method_definition @request.accept = 'application/rss+xml' get :respond_with_resource_and_blocks assert_equal 'Render RSS', @response.body.strip end |
#test_respond_to_skip_default_template_when_it_is_in_block ⇒ Object
150 151 152 153 154 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 150 def test_respond_to_skip_default_template_when_it_is_in_block @request.accept = '*/*' get :respond_to_skip_default_template assert_equal 'Render HTML', @response.body.strip end |
#test_respond_to_when_a_resource_is_given_as_option ⇒ Object
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 117 def test_respond_to_when_a_resource_is_given_as_option @request.accept = 'text/html' get :respond_with_resource assert_equal 'RespondTo HTML', @response.body.strip @request.accept = 'application/xml' get :respond_with_resource assert_equal 'Generated XML', @response.body.strip @request.accept = 'application/rss+xml' get :respond_with_resource assert_equal '406 Not Acceptable', @response.status @request.accept = 'application/json' assert_raise ActionView::MissingTemplate do get :respond_with_resource end end |
#test_respond_with_calls_to_format_on_resource ⇒ Object
67 68 69 70 71 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 67 def test_respond_with_calls_to_format_on_resource @request.accept = 'application/xml' get :index assert_equal 'Generated XML', @response.body.strip end |
#test_respond_with_forwads_extra_options_to_render ⇒ Object
110 111 112 113 114 115 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 110 def @request.accept = 'application/xml' get :respond_with_resource_and_options assert_equal 'Generated XML', @response.body.strip assert_equal 'http://test.host/', @response.headers['Location'] end |
#test_respond_with_inherits_format ⇒ Object
73 74 75 76 77 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 73 def test_respond_with_inherits_format @request.accept = 'application/xml' get :index assert_equal 'Generated XML', @response.body.strip end |
#test_respond_with_layout_rendering ⇒ Object
61 62 63 64 65 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 61 def test_respond_with_layout_rendering @request.accept = 'text/html' get :index assert_equal 'Index HTML', @response.body.strip end |
#test_respond_with_raises_error_if_could_not_respond ⇒ Object
85 86 87 88 89 90 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 85 def test_respond_with_raises_error_if_could_not_respond @request.accept = 'application/rss+xml' assert_raise ActionView::MissingTemplate do get :index end end |
#test_respond_with_renders_status_not_acceptable_if_mime_type_is_not_registered ⇒ Object
79 80 81 82 83 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 79 def test_respond_with_renders_status_not_acceptable_if_mime_type_is_not_registered @request.accept = 'text/csv' get :index assert_equal '406 Not Acceptable', @response.status end |
#test_respond_with_sets_content_type_properly ⇒ Object
98 99 100 101 102 103 104 105 106 107 108 |
# File 'lib/vendor/plugins/inherited_resources/test/respond_to_test.rb', line 98 def test_respond_with_sets_content_type_properly @request.accept = 'text/html' get :index assert_equal 'text/html', @response.content_type assert_equal :html, @response.template.template_format @request.accept = 'application/xml' get :index assert_equal 'application/xml', @response.content_type assert_equal :xml, @response.template.template_format end |