Commit Graph

2135 Commits

Author SHA1 Message Date
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
Akira Matsuda
edee2c7b3b stop to_sing method names
Module#methods are Symbols in Ruby >= 1.9
2012-06-06 19:33:38 +09:00
Piotr Sarnacki
6525002297 Include routes.mounted_helpers into integration tests
In integration tests, you might want to use helpers from engines that
you mounted in your application. It's not hard to add it by yourself,
but it's unneeded boilerplate. mounted_helpers are now included by
default. That means that given engine mounted like:

    mount Foo::Engine => "/foo", :as => "foo"

you will be able to use paths from this engine in tests this way:

    foo.root_path #=> "/foo"

(closes #6573)
2012-06-01 16:14:08 +02:00
Jeremy Friesen
4791822368 Extracted redirect logic from ActionController::Force::ClassMethods.force_ssl
Prior to this patch the existing .force_ssl method handles both defining
the filter and handling the logic for performing the redirect.

With this patch the logic for redirecting to the HTTPS protocol is
separated from the filter logic that determines if a redirect should
occur.  By separating the two levels of behavior, an instance method
for ActionController (i.e. #force_ssl_redirect) is exposed and available
for more granular SSL enforcement.

Cleaned up indentation.
2012-05-31 12:39:28 -04:00
Sergey Nartimov
1376f4cab1 no need to pass an empty block to button_to helper 2012-05-30 23:02:26 +03:00
Piotr Sarnacki
e4aaac1301 Fix sorting of helpers from different paths
When more than one directory for helpers is provided to a controller, it
should preserver the order of directories. Given 2 paths:

    MyController.helpers_paths = ["dir1/helpers", "dir2/helpers"]

helpers from dir1 should be loaded first. Before this commit, all
helpers were mixed and then sorted alphabetically, which essentially
would require to rename helpers to get desired order.

This is a problem especially for engines, where you would like to be
able to predict accurately which engine helpers will load first.

(closes #6496)
2012-05-28 06:58:48 +02:00
Aaron Patterson
513a0525c2 Merge pull request #2549 from trek/RoutingErrorForMissingControllers
When a route references a missing controller, raise ActionController::RoutingError with clearer message
2012-05-21 11:00:43 -07:00
Andrew White
79b38c386a Escape the extension when normalizing the action cache path.
Although no recognized formats use non-ASCII characters, sometimes they
can be included in the :format parameter because of invalid URLS. To
prevent encoding incompatibility errors we need to escape them before
passing the path to URI.unescape.

Closes #4379
2012-05-20 19:07:05 +01:00
David Chelimsky
dcce01132d Raise Assertion instead of RoutingError for routing assertion failures.
Before this change, assert_recognizes, assert_generates, and
assert_routing raised ActionController::RoutingError when they failed to
recognize the route.

This commit changes them to raise Assertion instead. This aligns with
convention for logical failures, and supports reporting tools that care
about the difference between logical failures and errors e.g. the
summary at the end of a test run.

- Fixes #5899
2012-05-20 06:21:32 -05:00
Dmitry Vorotilin
32a433e1c0 Show in log correct wrapped keys 2012-05-20 09:33:56 +04:00
angelo giovanni capilleri
47570d4f1f mispelling errors in render_text_test.rb and sqlite_specific_schema 2012-05-12 13:19:28 +02:00
Andrew White
e306ca3627 Refactor the handling of default_url_options in integration tests
This commit improves the handling of default_url_options in integration
tests by making behave closer to how a real application operates.

Specifically the following issues have been addressed:

* Options specified in routes.rb are used (fixes #546)
* Options specified in controllers are used
* Request parameters are recalled correctly
* Tests can override default_url_options directly
2012-05-10 20:42:57 +01:00
Kunal Shah
c09a92fb9e Add failing test re #3436 which demonstrates content_type is not respected when using the :head method/shortcut 2012-05-08 03:11:46 -04:00
José Valim
fef110d4a8 Merge pull request #5368 from andhapp/remove-max-stale
Minor test improvement
2012-05-07 07:35:42 -07:00
Steven Soroka
ec4045c02f added an integration test that checks ActionController::UnknownFormat renders 406 :not_acceptable 2012-05-06 00:27:45 -05:00
Steven Soroka
3532200576 Raise a rescuable exception when Rails doesn't know what to do with the format, rather than responding with a head :not_acceptable (406) 2012-05-06 00:27:45 -05:00
José Valim
7a093606f6 Merge pull request #4445 from nragaz/role_based_params_wrapping
specify a role for identifying accessible attributes when wrapping params
2012-05-04 21:45:32 +02:00
Alexey Vakhov
0d19a081ee Improve assert_template layout checking 2012-05-04 23:31:09 +04:00
Alexey Vakhov
4bd05a7bdc Fix assert_template :layout => nil assertion 2012-05-04 23:31:05 +04:00
Alexey Vakhov
df36c5f7ff Fix assert_template assertion with :layout option 2012-05-04 23:31:03 +04:00
Carlos Antonio da Silva
d03aa104e0 Force given path to http methods in mapper to skip canonical action checking
This fixes the following scenario:

    resources :contacts do
      post 'new', action: 'new', on: :collection, as: :new
    end

Where the /new path is not generated because it's considered a canonical
action, part of the normal resource actions:

    new_contacts POST   /contacts(.:format)          contacts#new

Fixes #2999
2012-05-04 15:17:04 -03:00
José Valim
5f62c86b50 Merge pull request #6148 from twinturbo/head-fix
Make ActionController#head pass rack-link
2012-05-03 22:52:08 -07:00
twinturbo
8edd21c66f Remove content-length as well 2012-05-03 17:24:05 -07:00
twinturbo
8eedd1a4a7 Make ActionController#head pass rack-link 2012-05-03 16:18:51 -07:00
Andy Lindeman
a544e00681 Allows assert_redirected_to to accept a regular expression 2012-05-03 09:16:38 -04:00
Nico
9a41edf0d9 added proc evaluation for action cache's layout parameter 2012-05-02 22:31:24 +02:00
Bogdan Gusiev
ce5c2b88fe ActionPack: remove tests for hash_for_* methods 2012-05-02 10:41:34 +03:00
Sergey Nartimov
9f64f20b8b allow send_file/send_data to skip disposition header, closes #2973 2012-04-30 10:12:55 +03:00
Andrew White
1c7bcde92d Add failing test case for #6053 2012-04-29 20:20:59 +01:00
Carlos Antonio da Silva
65df4c53c2 Add changelog entry for jsonp mimetype change, fix failing test
Fix failing test: Mime::JS generates "text/javascript"
2012-04-29 12:01:05 -03:00
Andrew White
7a80b69e00 Don't convert params if the request isn't HTML - fixes #5341 2012-04-29 10:15:54 +01:00
José Valim
d4dd1af341 Merge pull request #2321 from omjokine/master
JSONP should use mimetype application/javascript
2012-04-29 01:13:39 -07:00
Andrew White
5c18bdca32 Merge session arg with existing session instead of overwriting
This may break existing tests that are asserting the whole session contents
but should not break existing tests that are asserting individual keys - e.g:

class SomeControllerTest < ActionController::TestCase
  setup do
    session['user_id'] = 1
  end

  test "some test" do
    get :some_action, nil, { 'another_var' => 2 }

    # This assertion will now fail
    assert_equal({ 'another_var' => 2 }, session)

    # This assertion will still pass
    assert_equal 2, session['another_var]
  end
end

Fixes #1529.
2012-04-28 22:36:16 +01:00
Jose and Yehuda
56cdc81c08 Remove default match without specified method
In the current router DSL, using the +match+ DSL
method will match all verbs for the path to the
specified endpoint.

In the vast majority of cases, people are
currently using +match+ when they actually mean
+get+. This introduces security implications.

This commit disallows calling +match+ without
an HTTP verb constraint by default. To explicitly
match all verbs, this commit also adds a
:via => :all option to +match+.

Closes #5964
2012-04-24 22:52:26 -05:00
Rafael Mendonça França
4b85acba43 Remove unused test code.
ActionController::RoutingError are raised in router execution time and can not be
rescued in a controller.
2012-04-16 23:38:31 -03:00
Santiago Pastorino
4c1dcb0537 Merge pull request #5783 from rafaelfranca/default_url_options
Document that default_url_options must return a hash with symbolized keys
2012-04-08 20:10:14 -07:00
Rafael Mendonça França
9efe01ef0d default_url_options does not receive one argument anymore 2012-04-08 23:44:00 -03:00
Santiago Pastorino
500c9a161c Revert "Merge pull request #5750 from ahoward/master"
This reverts commit 174cf8b22064c3999dfa685014d5b31ac993bb54, reversing
changes made to 7ecd6a731bd60665bc6de94095137f0b2c4ada2a.
The reverted commit improved the performance in the wrong place, now we
have added this 6ddbd1844a6fd6aca2992f5f75c9f605cf89808f improvement.
2012-04-08 22:44:37 -03:00
Jeremy Kemper
0032da1b3e Merge pull request #5748 from ai/no_type_in_html5
Remove unnecessary in HTML 5 type attribute with default value
2012-04-08 06:56:44 -07:00
Rafael Mendonça França
ddbd1e4adb Make url_for work when option is nil and default_url_options has
stringified keys
2012-04-05 15:14:00 -03:00
Aaron Patterson
174cf8b220 Merge pull request #5750 from ahoward/master
mo fasta and mo betta the url_for
2012-04-05 09:31:39 -07:00
José Valim
91cb99e9e4 Merge pull request #4446 from ayamomiji/patch-1
prevent the cache sweeper ignores NoMethodError
2012-04-05 06:20:02 -07:00
Andrey A.I. Sitnik
f3fb416b89 Remove unnecessary in HTML 5 type attribute with default value 2012-04-05 15:32:37 +04:00
ara.t.howard
697991a201 carefully and quickly merge url_for options 2012-04-04 16:28:19 -06:00
Alexey Vakhov
7f6bb2d86d Tests :if option of force_ssl method 2012-04-01 09:44:49 +04:00
Santiago Pastorino
1141f71601 Remove the leading \n added by textarea on assert_select 2012-03-30 11:40:23 -03:00
ayaya
2ac67358a3 prevent the cache sweeper ignores NoMethodError 2012-03-29 11:09:42 +08:00
Santiago Pastorino
f0268d56af Set proper rendered_format when doing render :inline
Closes #5632
2012-03-28 18:53:09 -03:00
Piotr Sarnacki
5a5ca14cb2 Cover one more case in auth_token and remote forms
If embedding auth_token in remote forms is off and we
pass a value for auth_token it should respect it.
2012-03-28 18:03:16 +02:00
Piotr Sarnacki
128cfbdf4d config.action_view.embed_authenticity_token_in_remote_forms is true by default
Changed default value for `config.action_view.embed_authenticity_token_in_remote_forms`
to `false`. This change breaks remote forms that need to work also without javascript,
so if you need such behavior, you can either set it to `true` or explicitly pass
`:authenticity_token => true` in form options
2012-03-28 18:03:16 +02:00
Piotr Sarnacki
805b15ff35 Added config.action_view.embed_authenticity_token_in_remote_forms
There is a regression introduced in 16ee611fa, which breaks
remote forms that should also work without javascript. This commit
introduces config option that allows to configure this behavior
defaulting to the old behavior (ie. include authenticity token
in remote forms by default)

Conflicts:

	actionpack/CHANGELOG.md
2012-03-28 18:03:15 +02:00
Aaron Suggs
0c525f68f2 Add test for default_url_options[:port] 2012-03-28 13:31:37 +02:00
Piotr Sarnacki
67b2404cf9 If partial is rendered in controller, grab format from template
Previously `rendered_format` was set only based on mime types
passed in Accept header, which was wrong if first type from
Accept was different than rendered partial. The fix is to simply
move setting rendered_format to the place where template
is available and grab format from the template. If it fails
we can fallback to formats passed by Accept header.
2012-03-27 12:14:56 +02:00
José Valim
39514af7e7 Merge pull request #5480 from drogus/rendering-issues
Fix for #5440
2012-03-17 11:24:19 -03:00
kennyj
131083b819 Should use an argument in http_digest_authentication_test.rb 2012-03-17 20:23:28 +09:00
Sandeep
e7f8d50695 fixed - warning: ambiguous first argument; put parentheses or even spaces 2012-03-16 19:07:41 +05:30
Brian Lopez
6ce21af8aa fix typo in redirect test 2012-03-15 15:15:10 -07:00
Brian Lopez
cfcdd334de strip null bytes from Location header as well
add tests for stripping \r\n chars since that's already happening
2012-03-15 14:42:57 -07:00
Piotr Sarnacki
5b94e73d1a Remove ActionController::TestCase#rescue_action_in_public!
This method has no effect since exception handling was
moved to middlewares and ActionController tests do not
use any middlewares.
2012-03-15 04:14:49 +01:00
David Heinemeier Hansson
e884f4b6b7 Allow you to force the authenticity_token to be rendered even on remote forms if you pass true 2012-03-14 19:28:57 -04:00
David Heinemeier Hansson
a4c120f165 Do not include the authenticity token in forms where remote: true as ajax forms use the meta-tag value 2012-03-14 19:08:34 -04:00
José Valim
6db930cb5b Remove --http. 2012-03-14 22:30:01 +01:00
Piotr Sarnacki
1efeb072bf Merge pull request #5357 from bagilevi/sweeper-undefined-method-ignored
Don't ignore call to undefined method in Sweeper
2012-03-14 12:53:19 -07:00
Santiago Pastorino
4c16791f35 Add ActionController::HTTP
More info http://edgeguides.rubyonrails.org/api_app.html

[Carlos Antonio da Silva & Santiago Pastorino]
2012-03-14 12:46:23 -03:00
Santiago Pastorino
2ad34f46a1 Remove unused method 2012-03-12 16:09:40 -03:00
Michael Koziarski
411a826583 Merge pull request #5326 from lest/patch-2
configure how unverified request will be handled
2012-03-10 16:16:35 -08:00
Santiago Pastorino
d5d241cb2c @controller already includes url_helpers in with_routing method 2012-03-10 19:27:03 -02:00
Anuj Dutta
7d2bbb6ca4 Removed max-stale from the tests since it's a request cache-control directive, just for clarity sake. 2012-03-10 15:10:50 +00:00
Sergey Nartimov
245941101b configure how unverified request will be handled
can be configured using `:with` option in `protect_from_forgery` method
or `request_forgery_protection_method` config option

possible values:
- :reset_session (default)
- :exception

new applications are generated with:

    protect_from_forgery :with => :exception
2012-03-09 19:33:06 +03:00
Carlos Antonio da Silva
787617760c Add test case for #5307 2012-03-07 09:35:17 -03:00
Levente Bagi
b4b0fddb24 Don't ignore call to undefined method in Sweeper 2012-03-06 16:24:04 +00:00
Mario Visic
4c31ba9386 Failing test for mime responder respond_with using a block. 2012-03-05 20:21:01 -05:00
Sergey Nartimov
1e0387e8a1 force response body to be read in assert_template 2012-03-05 22:21:04 +03:00