Commit Graph

60 Commits

Author SHA1 Message Date
Aaron Patterson
4f7dbf50d9 test against controller responses
rather than calling methods on the controller.  We should test the
values returned by the controller rather than assuming that the
internals are implemented in a certain way.
2015-09-23 15:48:01 -07:00
Aaron Patterson
e4ba720c17 stop calling deprecated methods
We should be asking the mime type method for the mime objects rather
than via const lookup
2015-09-21 12:04:12 -07:00
Ronak Jangir
efa019b49c Added test for send_file_headers called with nil content type 2015-09-19 18:35:41 +05:30
Aaron Patterson
460079a771 let the superclass build the request and response
We should leverage the request / response objects that the superclass
has already allocated for us.
2015-07-08 14:15:53 -07:00
Vipul A M
6eced6a1fe Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
Guo Xiang Tan
f81bd7c67d Prevent state leak. 2014-06-05 18:34:39 -07:00
Zuhao Wan
1bcde3a771 Mime::PNG is already defined. 2014-06-05 22:04:06 +08:00
Zuhao Wan
35cc73e79d Unregister Mime::Type in teardown. 2014-05-28 22:54:12 +08:00
Guo Xiang Tan
77e25a777a Remove redundant tests method. 2014-05-11 15:29:36 -07:00
Guo Xiang
1f8933077d Remove tests method for test cases when controller can be inferred. 2014-05-03 23:55:23 -07:00
Aaron Patterson
caa981d881 Merge branch 'master' into laurocaetano-fix_send_file
* master: (536 commits)
  doc, API example on how to use `Model#exists?` with multiple IDs. [ci skip]
  Restore DATABASE_URL even if it's nil in connection_handler test
  [ci skip] - error_messages_for has been deprecated since 2.3.8 - lets reduce any confusion for users
  Ensure Active Record connection consistency
  Revert "ask the fixture set for the sql statements"
  Check `respond_to` before delegation due to: d781caaf31
  Adding Hash#compact and Hash#compact! methods
  MySQL version 4.1 was EOL on December 31, 2009 We should at least recommend modern versions of MySQL to users.
  clear cache on body close so that cache remains during rendering
  add a more restricted codepath for templates fixes #13390
  refactor generator tests to use block form of Tempfile
  Fix typo [ci skip]
  Move finish_template as the last public method in the generator
  Minor typos fix [ci skip]
  make `change_column_null` reversible. Closes #13576.
  create/drop test and development databases only if RAILS_ENV is nil
  Revert "Speedup String#to"
  typo fix in test name. [ci skip].
  `core_ext/string/access.rb` test what we are documenting.
  Fix typo in image_tag documentation
  ...

Conflicts:
	actionpack/CHANGELOG.md
2014-01-10 11:00:30 -08:00
Carlos Antonio da Silva
618d5317d3 Move the null mime type to request.format
TLDR: always return an object that responds to the query methods from
request.format, and do not touch Mime::Type[] lookup to avoid bugs.

---

Long version:

The initial issue was about being able to do checks like
request.format.html? for request with an unknown format, where
request.format would be nil.

This is where the issue came from at first in #7837 and #8085
(merged in cba05887dc3b56a46a9fe2779b6b228880b49622), but the
implementation went down the path of adding this to the mime type
lookup logic.

This unfortunately introduced subtle bugs, for instance in the merged
commit a test related to send_file had to be changed to accomodate the
introduction of the NullType.

Later another bug was found in #13064, related to the content-type being
shown as #<Mime::NullType:...> for templates with localized extensions
but no format included. This one was fixed in #13133, merged in
43962d6ec50f918c9970bd3cd4b6ee5c7f7426ed.

Besides that, custom handlers were not receiving the proper template
formats anymore when passing through the rendering process, because of
the NullType addition. That was found while migrating an application
from 3.2 to 4.0 that uses the Markerb gem (a custom handler that
generates both text and html emails from a markdown template).

---

This changes the implementation moving away from returning this null
object from the mime lookup, and still fixes the initial issue where
request.format.zomg? would raise an exception for unknown formats due to
request.format being nil.
2013-12-23 16:16:49 -02:00
Lauro Caetano
71d19f1517 Fix stream closing when sending file with ActionController::Live included.
Fixes #12381
2013-11-30 16:06:52 -02:00
Angelo Capilleri
c2267db383 return Mime::NullType if format is unknown
If a request has an unknown format, the methods html?, xml?, json? ...etc
not raise an Exception.

This patch add a class Mime::NullType, that is returned when  request.format is unknown
and it responds false to the methods that ends with '?' and true to 'nil?'.

It refers to #7837, this issue is considered a improvement not a bug.
2012-12-22 09:18:08 +01:00
Elia Schito
5d8faa683e Accept symbols as #send_data :disposition value 2012-11-27 00:21:12 +01:00
Yves Senn
4d7f53379a cleanup, remove trailing whitespace within actionpack 2012-10-27 16:03:18 +02:00
Aaron Patterson
a6bdae1c19 flushing output should write to the stream rather than mutating the response object 2012-07-29 17:02:00 -07:00
Sergey Nartimov
9f64f20b8b allow send_file/send_data to skip disposition header, closes #2973 2012-04-30 10:12:55 +03:00
Santiago Pastorino
2ad34f46a1 Remove unused method 2012-03-12 16:09:40 -03:00
Sergey Nartimov
1e9e88fcd3 remove checks for encodings availability 2011-12-25 14:34:58 +03:00
Esad Hajdarevic
2a61d47b55 Make send_file guess content-type from file extension, if type wasn't supplied (Issue #1847). Update tests & documentation. 2011-06-28 06:58:28 +02:00
Neeraj Singh
73f0e1a842 Use assert_respond_to because it has better error messaging
[#4628 state:resolved]

Signed-off-by: José Valim <jose.valim@gmail.com>
2010-05-18 02:12:06 +02:00
Cezary Baginski
490a3335d5 Action Pack: fix tests with -K*, work around Ruby 1.9.1 constant lookup.
[#4473 state:committed]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2010-04-25 17:00:20 -07:00
Carlhuda
5e2bd08023 Makes send_file work again by deferring to Rack::Sendfile.
* Add the Rack::Sendfile middleware
  * Make the header to use configurable via config.action_dispatch.x_sendfile_header (default to "X-Sendfile"). 
  * Add Railties tests to confirm that these work
  * Remove the :stream, :buffer_size, and :x_senfile default options to send_file
  * Change the log subscriber to always say "Sent file"
  * Add deprecation warnings for options that are now no-ops

Note that servers can configure this by setting X-Sendfile-Type. Hosting companies and those creating packages of servers specially designed for Rails applications are encouraged to specify this header so that this can work transparently.
2010-02-23 17:06:35 -08:00
Carlhuda
3345af61fb Fix streaming by having it create a File object, which can be handled by Rack servers as appropriate 2010-02-23 15:37:17 -08:00
Carlhuda
a3c6ad7d5e Fix a bunch of pending tests by providing an introspection mode for the Response object that does up-front parsing of the headers to populate things like @etag 2010-02-19 19:19:20 -08:00
Joshua Peek
7d7f9ccfdf Reinstate pending tests that were supposed to be fixed before the
beta.

Shout louder this time so they actually get fixed.
2010-02-19 09:34:22 -06:00
Yehuda Katz
503ce1d01c Update cache_control to be a Hash of options that is used to build the header.
* Significantly simplifies setting and modifying cache control in other areas
2009-08-02 19:39:33 -04:00
Jeremy Kemper
f2a35723c8 Ruby 1.9: fix encoding for test_file_stream 2009-08-01 20:26:05 -07:00
Sava Chankov
ec94c2550d Ruby 1.9: fix Content-Length for multibyte send_data streaming
[#2661 state:resolved]

Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
2009-08-01 20:25:59 -07:00
Joshua Peek
7837da41a3 send_data should set Content-Length as a string 2009-06-25 14:47:15 -05:00
Yehuda Katz + Carl Lerche
65102c8f1a Cleaning up more tests and code that needed to work in both old and new base 2009-06-17 16:51:51 -07:00
Yehuda Katz + Carl Lerche
5a8a550a45 Finish making things pass with updated internal content_type semantics 2009-06-15 11:21:08 -07:00
Pratik Naik
1a52b246eb Add HTTP Authentication to the new base 2009-05-22 00:29:47 +02:00
Pratik Naik
386ff66e5e Add Streaming to new base 2009-05-21 21:48:42 +02:00
Joshua Peek
a8b75c480f Functional test runner finalizes response just like the integration test runner. In both runners, the @response object will now behave the same.
Some functional tests will need to be updated if they are relying on preprocessed data on the response.
2009-05-02 14:57:40 -05:00
Carl Lerche & Yehuda Katz
906aebceed Bring abstract_controller up to date with rails/master
Resolved all the conflicts since 2.3.0 -> HEAD. Following is a list
of commits that could not be applied cleanly or are obviated with the
abstract_controller refactor. They all need to be revisited to ensure
that fixes made in 2.3 do not reappear in 3.0:

2259ecf368e6a6715966f69216e3ee86bf1a82a7
AR not available
  * This will be reimplemented with ActionORM or equivalent

06182ea02e92afad579998aa80144588e8865ac3
implicitly rendering a js response should not use the default layout
[#1844 state:resolved]
  * This will be handled generically

893e9eb99504705419ad6edac14d00e71cef5f12
Improve view rendering performance in development mode and reinstate
template recompiling in production [#1909 state:resolved]
  * We will need to reimplement rails-dev-boost on top of the refactor;
    the changes here are very implementation specific and cannot be
    cleanly applied. The following commits are implicated:

      199e750d46c04970b5e7684998d09405648ecbd4
      3942cb406e1d5db0ac00e03153809cc8dc4cc4db
      f8ea9f85d4f1e3e6f3b5d895bef6b013aa4b0690
      e3b166aab37ddc2fbab030b146eb61713b91bf55
      ae9f258e03c9fd5088da12c1c6cd216cc89a01f7
      44423126c6f6133a1d9cf1d0832b527e8711d40f

0cb020b4d6d838025859bd60fb8151c8e21b8e84
workaround for picking layouts based on wrong view_paths
[#1974 state:resolved]
  * The specifics of this commit no longer apply. Since it is a two-line
    commit, we will reimplement this change.

8c5cc66a831aadb159f3daaffa4208064c30af0e
make action_controller/layouts pick templates from the current instance's
view_paths instead of the class view_paths [#1974 state:resolved]
  * This does not apply at all. It should be trivial to apply the feature
    to the reimplemented ActionController::Base.

87e8b162463f13bd50d27398f020769460a770e3
fix HTML fallback for explicit templates [#2052 state:resolved]
  * There were a number of patches related to this that simply compounded
    each other. Basically none of them apply cleanly, and the underlying
    issue needs to be revisited. After discussing the underlying problem
    with Koz, we will defer these fixes for further discussion.
2009-04-13 15:18:45 -07:00
Jeremy Kemper
91d2740595 Return body parts directly to Rack rather than building a response string ourselves. Allows Rack middleware to orchestrate response building. 2009-03-12 21:47:34 -07:00
Jeremy Kemper
1c36172c13 Ruby 1.9 compat: rename deprecated assert_raises to assert_raise.
[#1617 state:resolved]
2009-03-08 13:11:58 -07:00
Joshua Peek
a0f2b1d95d Reorganize ActionController folder structure 2009-01-27 18:17:39 -06:00
Jeremy Kemper
35fa007313 Include process methods in ActionController::TestCase only. No need to alias_method_chain :process either. 2009-01-07 14:49:05 -08:00
=?utf-8?q?Adam=20Cig=C3=A1nek?=
fcd58dc27a Allow use of symbols for :type option of ActionController::Streaming#send_file/#send_data [#1232 state:resolved]
Signed-off-by: Frederick Cheung <frederick.cheung@gmail.com>
2008-12-21 18:58:55 +00:00
Joshua Peek
3da1b94d07 Use status response accessor instead of the 'Status' header 2008-12-19 15:05:51 -06:00
Hongli Lai (Phusion
9e2b4a10f7 Do not output an ETag header if response body is blank or when sending files with send_file(... :xsendfile => true) [#1578 state:committed]
Signed-off-by: David Heinemeier Hansson <david@loudthinking.com>
2008-12-16 12:30:28 +01:00
Joshua Peek
30204c4e66 Set global ActionController::Base.view_paths for test cases 2008-07-12 14:11:51 -05:00
Joshua Peek
339491a6b3 Set precompiled fixture load path constant to speed up tests 2008-06-25 15:24:12 -05:00
Jeremy Kemper
9889d86a6c Introduce send_file :x_sendfile => true to send an X-Sendfile response header.
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8628 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-11 22:07:04 +00:00
Jeremy Kemper
9d755f1983 require abstract_unit directly since test is in load path
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8564 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2008-01-05 13:32:06 +00:00
David Heinemeier Hansson
9b46f69381 Allow send_file/send_data to use a registered mime type as the :type parameter #7620 [jonathan]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6233 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-02-25 20:16:58 +00:00
David Heinemeier Hansson
9e4c8b8858 Fix tests depending too deep
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@6169 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
2007-02-19 02:25:01 +00:00