Commit Graph

2107 Commits

Author SHA1 Message Date
Bogdan Gusiev
6777f7b75d AS::Callbacks: deprecate monkey patch of object callbacks 2012-09-07 14:42:31 +03:00
David Heinemeier Hansson
ed5c938fa3 Added controller-level etag additions that will be part of the action etag computation *Jeremy Kemper/DHH* 2012-08-29 15:06:30 -05:00
David Heinemeier Hansson
502d5e24e2 Add automatic template digests to all CacheHelper#cache calls (originally spiked in the cache_digests plugin) *DHH* 2012-08-29 14:23:56 -05:00
schneems
0b6175ac2d Add Missing Keys from Journey on failed URL format
Many named routes have keys that are required to successfully resolve. If a key is left off like this:

    <%= link_to 'user', user_path %>

This will produce an error like this:

    No route matches {:action=>"show", :controller=>"users"}

Since we know that the :id is missing, we can add extra debugging information to the error message.

    No route matches {:action=>"show", :controller=>"users"} missing required keys: [:id]


This will help new and seasoned developers look closer at their parameters. I've also subclassed the routing error to be clear that this error is a result of attempting to generate a url and not because the user is trying to visit a bad url. 

While this may sound trivial this error message is misleading and confuses most developers. The important part isn't what's in the options its's what's missing. Adding this information to the error message will make debugging much more obvious. 

This is the sister pull request of https://github.com/rails/journey/pull/44 which will be required to get they missing keys into the correct error message. 

Example Development Error in Rails: http://cl.ly/image/3S0T0n1T3421
2012-08-28 08:53:45 -07:00
Piotr Sarnacki
e1ffd82e76 Deprecate AV::RecordIdentifier in controllers
Methods provided by RecordIdentifier are not widely used in controllers
nowadays as they're view specific (this is probably a legacy left after
RJS rendering directly in controllers). However if people still need to
use it, it's trivial to include ActionView::RecordIdentifier by
themselves.
2012-08-28 11:19:37 +02:00
Piotr Sarnacki
9b0ac0bc74 Use ActionView::Base.logger instead of AC::Base.logger 2012-08-28 10:51:05 +02:00
Piotr Sarnacki
ba83aa7f03 Move action_controller/vendor/html-scanner to action_view
This is another step in moving Action View's dependencies in Action Pack
to Action View itself. Also, HtmlScanner seems to be better suited for
views rather than controllers.
2012-08-28 10:51:03 +02:00
Piotr Sarnacki
264624049e Move ActionController::RecordIdentifier to ActionView
Since it's more about DOM classes and ids it belongs to Action View
better. What's more, it's more convenient to make it part of Action View
to follow the rule that Action Pack can depend on Action View, but not
the other way round.
2012-08-28 10:51:03 +02:00
tomykaira
503c1c04ad Access @rs only through attr_accessor 2012-08-20 21:47:00 +09:00
Rafael Mendonça França
546497d027 Extract common controllers to abstract_unit 2012-08-13 21:43:18 -03:00
Aaron Patterson
581a927710 set the controller under test so we no longer need the reset! method 2012-08-09 18:06:13 -07:00
Xavier Noria
447b6a4e67 removes usage of Object#in? from the code base (the method remains defined by Active Support)
Selecting which key extensions to include in active_support/rails
made apparent the systematic usage of Object#in? in the code base.
After some discussion in

    5ea6b0df9a

we decided to remove it and use plain Ruby, which seems enough
for this particular idiom.

In this commit the refactor has been made case by case. Sometimes
include? is the natural alternative, others a simple || is the
way you actually spell the condition in your head, others a case
statement seems more appropriate. I have chosen the one I liked
the most in each case.
2012-08-06 00:30:02 +02:00
Aaron Patterson
c391919180 make sure the body finishes rendering before checking response closure 2012-08-03 00:27:39 -04:00
Armand du Plessis
c62abed8ca Collapsed dual checks (one for content headers and one for content) into a single check.
Rails includes a single character body to a head(:no_content) response to work around an old Safari bug where headers were ignored if no body sent.

This patch brings the behavior slightly closer to spec if :no_content/204 is explicity requested via a head only response.

Status comparison done on symbolic and numeric values

Not returning any content when responding with head and limited to a status code that explicitly states no content will be returned - 100..199, 204, 205, 304.
2012-08-02 16:01:08 -07:00
Rafael Mendonça França
6e523766d8 Merge pull request #7240 from steveklabnik/fix_2301
Fix for digest authentication bug - issue #2301 in rails/rails
2012-08-02 13:50:54 -07:00
Xavier Noria
5ea6b0df9a load active_support/core_ext/object/inclusion in active_support/rails 2012-08-02 21:59:22 +02:00
Arthur Smith
b3e2abc4b1 Fix for digest authentication bug - issue #2301 in rails/rails 2012-08-02 15:24:08 -04:00
Santiago Pastorino
b6ab441772 html_escape should escape single quotes
https://www.owasp.org/index.php/XSS_%28Cross_Site_Scripting%29_Prevention_Cheat_Sheet#RULE_.231_-_HTML_Escape_Before_Inserting_Untrusted_Data_into_HTML_Element_Content
Closes #7215
2012-07-31 22:26:52 -03:00
Aaron Patterson
fa3c4ea6d0 close the response when the response body is set so that normal render calls will work 2012-07-29 21:43:07 -07:00
Aaron Patterson
4509494f70 header hash is duped before being sent up the rack stack 2012-07-29 21:43:07 -07:00
Aaron Patterson
619e7c8db8 make sure set_response! sets the correct response object 2012-07-29 21:43:06 -07:00
Aaron Patterson
38cfbb8aa7 Controller actions are processed in a separate thread for live
responses.

Processing controller actions in a separate thread allows us to work
around the rack api - we can allow the user to set status and headers,
then block until the first bytes are written.  As soon as the first
bytes are written, the main thread can return the status, headers, and
(essentially) a queue for the body.
2012-07-29 21:43:05 -07:00
Aaron Patterson
af0a9f9eef added live responses which can be written and read in separate threads 2012-07-29 21:43:05 -07: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
Aaron Patterson
19e68e9d47 remove dead test 2012-07-29 16:00:50 -07:00
Aaron Patterson
356787fce8 adding a buffered stream to the response object 2012-07-29 15:51:21 -07:00
Rafael Mendonça França
82667c84e1 Remove warning renaming the test classes to use the test convention 2012-07-29 17:47:05 -03:00
Aaron Patterson
f79b29a5a8 this test is not a controller test, so switch to AS::TC 2012-07-28 20:30:52 -07:00
Brian John
35fe3107a3 Clean up Sweeper controller accessor when an Error is raised 2012-07-20 05:49:45 -05:00
Piotr Sarnacki
542637e679 Fix indentation. 2012-07-11 02:07:25 +02:00
Piotr Sarnacki
df40d79fdc Don't raise an error if http auth token isn't well formatted
When someone sends malformed authorization header, like:

    Authorization: Token foobar

given token should be just ignored and resource should not be authorized,
instead of raising error. Before this patch controller would return 401 header
only for well formed tokens, like:

    Authorization: Token token=foobar

and would return 500 in former case.
2012-07-11 01:56:38 +02:00
Aaron Patterson
d481170251 deprecate describe without a block.
minitest/spec provides `describe`, so deprecate the rails version and
have people use the superclass version
2012-07-09 13:13:59 -07:00
Carlos Antonio da Silva
ea7b48b074 Use "instance_accessor" for flash types class attribute 2012-07-07 09:16:48 -03:00
kennyj
238a4253bf Added support add_flash_types 2012-07-07 17:07:57 +09:00
kennyj
1498071b92 Remove unused code. 2012-07-07 14:59:49 +09:00
Mircea Pricop
021f3d24f3 Prevent conflict between mime types and Object methods
Assuming the type ":touch", Collector.new was calling
send(:touch), which instead of triggering method_missing
and generating a new collector method, actually
invoked the private method `touch` inherited from
Object.

By generating the method for each mime type as it
is registered, the private methods on Object can
never be reached by `send`, because the `Collector`
will have them before `send` is called on it.

To do this, a callback mechanism was added to Mime::Type

This allows someone to add a callback for whenever
a new mime type is registered. The callback then
gets called with the new mime as a parameter.

This is then used in AbstractController::Collector
to generate new collector methods after each mime
is registered.
2012-07-06 20:38:23 +02:00
Aaron Patterson
a7826bd8b7 Merge branch 'master' into testclean
* master:
  Add documentation for inheritance_column method
  Use ArgumentError vs. RuntimeError, which is more precise.
  CSV fixtures aren't supported by default anymore, update generated test_helper.rb to reflect that
  fix quoting for ActiveSupport::Duration instances
  Add few information on the field types
  Add the options method to action_controller testcase.
2012-07-05 14:03:57 -07:00
François de Metz
0303c2325f Add the options method to action_controller testcase.
Signed-off-by: François de Metz <francois@stormz.me>
2012-07-04 15:00:00 +02:00
Aaron Patterson
b5442b5a3a test should be testing to_param not to_s, remove Array subclass 2012-07-03 16:35:07 -07:00
Bogdan Gusiev
88230b7cf7 AS::Callbacks: deprecate monkey patch code
Deprecate usage of filter object with #before and #after
methods as around callback
2012-06-26 09:21:36 +03:00
Carlos Antonio da Silva
ebe8a45444 Merge pull request #6805 from tim-vandecasteele/uploadedfile-paramify
Don't paramify ActionDispatch::Http::UploadedFile in tests
2012-06-23 13:06:12 -07:00
Tim Vandecasteele
8471edc672 Don't paramify ActionDispatch::Http::UploadedFile in tests
To test uploading a file without using fixture_file_upload, a posted
ActionDispatch::Http::UploadedFile should not be paramified (just like
Rack::Test::UploadedFile).
(Rack::Test::UploadedFile and ActionDispatch::Http::UploadedFile don't
share the same API, tempfile is not accessible on
Rack::Test::UploadedFile as discussed in
https://github.com/brynary/rack-test/issues/30)
2012-06-22 09:27:41 +02:00
Arun Agrawal
6f6111e089 Removed warnings.
1. Change in test name as already defined.
2. ambiguous first argument; put parentheses or 
even spaces
2012-06-21 17:01:57 +05:30
Carlos Antonio da Silva
4d69cdbdd7 Merge pull request #6777 from route/logger_in_metal_tests
Added test for case when view doesn't have logger method when using 
ActionController::Metal controller.
2012-06-19 05:43:07 -07:00
Dmitry Vorotilin
e8f9e667e4 Added test for case when view doesn't have logger method when using ActionController::Metal controller. 2012-06-19 09:45:15 +04:00
James Tucker
0b4e8c8d84 Ensure that cache-control headers are merged
There are several aspects to this commit, that don't well fit into broken down
commits, so they are detailed here:

 * When a user uses response.headers['Cache-Control'] = some_value, then the
   documented convention in ConditionalGet is not adhered to, in this case,
   response.cache_control is ignored due to `return if
   self[CACHE_CONTROL].present?`
 * When a middleware sets cache-control headers that would clobber, they're
   converted to symbols directly, without underscores. This would lead to bugs.
 * Items that would live in :extras if set through expires_in, are placed
   directly in the @cache_control hash, and not respected in many cases
   (somewhat adhering to the aforementioned documentation).
 * Although quite useless, any directive named 'extras' would be ignored.

The general convention applied is that expires_* take precedence, but no longer
overwrite everything and expires_* are ALWAYS applied, even if the header is
set.

I am still unhappy about the contents of this commit, and the code in general.
Ideally it should be refactored to no longer use :extras. I'd likely recommend
expanding @cache_control into a class, and giving it the power to handle the
merge in a more efficient fashion. Such a commit would be a larger change that
could have additional semantic changes for other libraries unless they utilize
expires_in in very standard ways.
2012-06-18 16:49:03 -07:00
kennyj
c42a7a0082 Support unicode character route in config/routes.rb. 2012-06-16 00:22:16 +09:00
Aaron Patterson
b92860fa88 adding a test for #6459 2012-06-14 14:17:06 -07:00
Santiago Pastorino
0e06e8a692 This consider_all_requests_local doesn't make sense
This middleware is only for Public Exceptions.
This follows bd8c0b8a
2012-06-12 13:25:11 -03:00
Santiago Pastorino
bd8c0b8a7a Return proper format on exceptions 2012-06-11 18:07:30 -03:00