Commit Graph

5363 Commits

Author SHA1 Message Date
Sergio Romano
540d153531 ActionController::Parameters#require now accepts FalseClass values
Fixes #15685.
2014-06-13 14:42:38 -03:00
Larry Lv
fdb1059795 Fix parsed token value with header Authorization token=. 2014-06-13 16:29:15 +08:00
Aaron Patterson
caf1bfccc6 use Ruby for mocking 2014-06-12 09:19:59 -07:00
Kuldeep Aggarwal
fca73eeb87 remove warnings
warning: assigned but unused variable - scope_called, path and strexp
2014-06-12 00:27:58 +05:30
Yves Senn
71f99be858 Merge pull request #15545 from zuhao/refactor_actionpack_assert_select_test
Restore test deliveries for ActionMailer.
2014-06-08 15:55:20 +02:00
Matthew Draper
6a89850dfe Handle client disconnect during live streaming
.. even when the producer is blocked for a write.
2014-06-08 07:21:14 +09:30
Xavier Noria
f84d081faf adds some details to the rationale of converted_arrays [ci skip] 2014-06-07 13:30:03 +02:00
Xavier Noria
f712f89961 adds a regression test for the strong params converted arrays cache
This is a regression test for 29844dd.
2014-06-07 13:19:16 +02:00
Xavier Noria
1ecada20d1 Revert "Convert StrongParameters cache to a hash. This fixes an unbounded"
We cannot cache keys because arrays are mutable. We rather want to cache
the arrays. This behaviour is tailor-made for the usage pattern strongs
params is designed for.

In a forthcoming commit I am going to add a test that covers why we need
to cache by value.

Every strong params instance has a live span of a request, the cache goes
away with the object. Since strong params have such a concrete intention,
it would be interesting to see if there are actually any real-world use
cases that are an actual leak, one that practically may matter.

I am not convinced that the theoretical leak has any practical consequences,
but if it can be shown there are, then I believe we should either get rid of
the cache (which is an optimization), or else wipe it in the mutating API.

This reverts commit e63be2769c039e4e9ada523a8497ce3206cc8a9b.
2014-06-07 13:19:16 +02:00
Zuhao Wan
64edb6cb19 Restore test deliveries for ActionMailer. 2014-06-07 00:18:50 +08:00
Guo Xiang Tan
5cc789930f Remove redundant code. 2014-06-05 18:34:39 -07:00
Guo Xiang Tan
f81bd7c67d Prevent state leak. 2014-06-05 18:34:39 -07:00
Matthew Draper
141e6e8a2f Merge pull request #15530 from zuhao/refactor_actionpack_reloader_test
Reset callbacks after test.
2014-06-06 03:24:48 +09:30
Yves Senn
4f58b90bab Merge pull request #15532 from zuhao/refactor_actionpack_response_test
Restore Response.default_headers after test.
2014-06-05 16:55:17 +02:00
Zuhao Wan
e767be0779 Restore Response.default_headers after test. 2014-06-05 22:52:13 +08:00
Zuhao Wan
d9be7ad7cf Avoid hard-coded value in test setup/teardown. 2014-06-05 22:39:03 +08:00
Zuhao Wan
5faf77fe7a Reset callbacks after test.
Otherwise the state of callback chain is leaked.
2014-06-05 22:30:53 +08:00
Yves Senn
da19e0d132 Merge pull request #15529 from zuhao/refactor_actionpack_mime_type_test
Make sure Mime::Type is not altered after tests.
2014-06-05 16:08:22 +02:00
Zuhao Wan
1bcde3a771 Mime::PNG is already defined. 2014-06-05 22:04:06 +08:00
Zuhao Wan
6a75e2ce10 Avoid hardcoded value in test setup/teardown. 2014-06-05 21:03:41 +08:00
Guillermo Iguaran
4818bb36ac Merge pull request #15498 from zenspider/fix_memory_leak
Convert StrongParameters cache to a hash. This fixes an unbounded memory leak
2014-06-03 21:48:17 -05:00
Ryan Davis
e63be2769c Convert StrongParameters cache to a hash. This fixes an unbounded
memory leak demonstrated on @tenderlove's latest blog post:

http://tenderlovemaking.com/2014/06/02/yagni-methods-are-killing-me.html
2014-06-03 16:57:22 -07:00
Rafael Mendonça França
489a8f2a44 Partially revert deprecation of *_filter
We are going to deprecate only on Rails 5 to make easier plugin
maintainers support different Rails versions. Right now we are only
discouraging their usage.

This reverts commit 6c5f43bab8206747a8591435b2aa0ff7051ad3de.

Conflicts:
	actionpack/CHANGELOG.md
2014-06-03 19:53:28 -03:00
Rafael Mendonça França
18d19bf2a4 Merge pull request #15349 from tgxworld/remove_duplicated_method_call
Remove duplicated HashWithIndifferentAccess#with_indifferent_access.
2014-06-03 19:10:33 -03:00
Aaron Patterson
cc26b6b7bc Routes specifying 'to:' must be a string that contains a "#" or a rack
application.  Use of a symbol should be replaced with `action: symbol`.
Use of a string without a "#" should be replaced with `controller: string`.
2014-06-03 14:05:42 -07:00
Aaron Patterson
4097ff5c5f use the factory method to construct the mapping 2014-06-03 11:42:45 -07:00
Aaron Patterson
e3df1dd047 add tests for mixing :to and controller / action 2014-06-03 11:36:32 -07:00
Aaron Patterson
a21707116a add tests for nested lambda constraints 2014-06-03 11:33:53 -07:00
Aaron Patterson
16e210745c test with an empty via 2014-06-03 11:33:50 -07:00
Aaron Patterson
57d0da86b4 add a test for missing "via" parameter 2014-06-03 11:33:50 -07:00
Aaron Patterson
74b73f132a Mapping never actually uses @set, so rm 2014-05-29 16:13:29 -07:00
Aaron Patterson
da2cf937aa no more is_a checks on instantiation 2014-05-29 15:45:42 -07:00
Aaron Patterson
bb207ea7b6 Path::Pattern is instantiated internally, so make the contructor require a strexp object 2014-05-29 15:44:54 -07:00
Aaron Patterson
5682596db7 Strexp#names is only used in a test, so rm 2014-05-29 15:31:45 -07:00
Aaron Patterson
15ffbedf3b add an alternate constructor to Strexp that takes a string 2014-05-29 15:23:30 -07:00
Aaron Patterson
3a102a58f4 use a parser to extract the group parts from the path 2014-05-29 14:57:48 -07:00
Aaron Patterson
295e912211 Merge branch 'master' into mapper
* master:
  Update url to rake docs [ci skip]
  Name#model_name doesn't return a String object
  Result sets never override a model's column type
  [ci skip] Make last note show up in postgresql guide.
  Add missing `:param` option from the docs for Mapper#match [ci skip] Option discovered by @zackperdue in #14741, implemented in #5581.
  Add @senny's changed from #14741, including code font for `resources` options, and wrapped to 80 chars. [ci skip]
  Use github url for homepage of log4r [ci skip]
  Remove TODO.
  Ensure we always use instances of the adapter specific column class
  Fix indentation from 1b4b26f [ci skip]
  [ci skip] Improve form_helpers.md guide.
  Clear inflections after test.
  Remove unnecessary include for integration tests.
  Added documentation for the :param option for resourceful routing
2014-05-29 10:56:33 -07:00
Aaron Patterson
8ed1a562c6 "controllers" should be a valid path name 2014-05-29 10:55:59 -07:00
Matthew Draper
29f8eae3fa Merge pull request #15061 from tgxworld/remove_unnecessary_include
Remove unnecessary include for integration tests.
2014-05-29 21:33:12 +09:30
Guillermo Iguaran
03ee41948d Merge pull request #15399 from tgxworld/remove_todo_router_test
Remove TODO.
2014-05-28 22:12:13 -05:00
Guo Xiang Tan
b1bc553385 Remove TODO. 2014-05-28 20:06:08 -07:00
Aaron Patterson
6cabf1d19f add a test for controllers without colons 2014-05-28 17:05:54 -07:00
Yves Senn
b8be14acdc Merge pull request #15384 from zuhao/refactor_actionpack_params_wrapper_test
Clear inflections after test.
2014-05-29 01:13:17 +02:00
Aaron Patterson
e135bbacb9 add a test for existing mapper functionality
I'm not sure if this is actually used, but I'm adding a test to define
the behavior
2014-05-28 15:15:43 -07:00
Aaron Patterson
5bbab5110b add tests for argument error cases 2014-05-28 15:14:49 -07:00
Zuhao Wan
781f8a8a33 Clear inflections after test. 2014-05-28 23:33:10 +08:00
Santiago Pastorino
abd6461e28 Merge pull request #15386 from zuhao/refactor_actionpack_request_forgery_protection_test
Avoid hardcoded `request_forgery_protection_token` value in teardown.
2014-05-28 12:03:50 -03:00
Santiago Pastorino
9ae3f5ff1c Merge pull request #15388 from zuhao/refactor_actionpack_send_file_test
Unregister Mime::Type in teardown.
2014-05-28 12:00:35 -03:00
Zuhao Wan
35cc73e79d Unregister Mime::Type in teardown. 2014-05-28 22:54:12 +08:00
Santiago Pastorino
c711c90bae Merge pull request #15385 from zuhao/refactor_actionpack_render_other_test
Add and remove renderer inside the test to prevent leak.
2014-05-28 11:39:11 -03:00
Zuhao Wan
e354b335ce Avoid hardcoded value in teardown. 2014-05-28 22:35:48 +08:00
Zuhao Wan
2ba945253b Add and remove renderer inside the test to prevent leak. 2014-05-28 22:24:22 +08:00
Yves Senn
b22b188223 Merge pull request #15383 from zuhao/refactor_actionpack_localized_templates_test
Move I18n.locale setting into setup and teardown.
2014-05-28 16:00:32 +02:00
Zuhao Wan
1407315423 Move I18n.locale setting into setup and teardown. 2014-05-28 21:50:30 +08:00
Zuhao Wan
51dc7c2adb Add with_default_charset helper. 2014-05-28 21:17:16 +08:00
Rafael Mendonça França
6c5f43bab8 Deprecate all *_filter callbacks in favor of *_action callbacks
This is the continuation of the work started at
9d62e04838f01f5589fa50b0baa480d60c815e2c
2014-05-27 19:10:14 -03:00
Aaron Patterson
2ffa126f79 PARAMETERS_KEY is only used in the request, so move the constant there 2014-05-27 14:46:04 -07:00
Aaron Patterson
cfdab77d1f Merge branch 'constraints'
* constraints:
  rm reset_parameters because we automatically do it from 9ca4839a
  move path_parameter encoding check to the request object
  dispatcher doesn't need `call` anymore
  call `serve` with the request on dispatchers
  constraints class does not need the request class anymore
  give all endpoints a superclass
  skip the build business if the stack is empty
  stop hardcoding path_parameters and get it from the request
  we do not need to cache rack_app
  a redirect is not a dispatcher by definition, so eliminate test
  push is_a check up to where the Constraints object is allocated
  pass the request object to the application
  pass a request to `matches?` so we can avoid creating excess requests
  nothing is passed to `rack_app` anymore, so rm the params
  one fewer is_a check
  Constraints#app should never return another Constraints object, so switch to if statement
  eliminate dispatcher is_a checks
  push is_a?(Dispatcher) check in to one place
  Always construct route objects with Constraint objects

Conflicts:
	actionpack/lib/action_controller/metal.rb
2014-05-27 14:40:55 -07:00
Aaron Patterson
406b1b6464 rm reset_parameters because we automatically do it from 9ca4839a 2014-05-27 14:24:30 -07:00
Guo Xiang Tan
223e118a3c Remove duplicated HashWithIndifferentAccess#with_indifferent_access. 2014-05-26 12:59:02 -07:00
Matthew Draper
72045b2a9f Skip individual tests upon Dalli::RingError
Unlike the outer `rescue`, this one is much more precise about what we
want to handle: a connection failure (`Dalli::RingError`) is not
relevant to what we're testing here. But other Dalli errors may well be
indicating an actual problem.
2014-05-27 04:45:53 +09:30
Aaron Patterson
b18f22d15c pass the request object to the application 2014-05-25 14:26:48 -07:00
Zuhao Wan
839d461b61 The correct status to test should be :switching_protocols. 2014-05-25 16:17:22 +08:00
Aaron Patterson
633589c140 push is_a?(Dispatcher) check in to one place 2014-05-24 19:03:12 -07:00
Aaron Patterson
229c9ed896 Always construct route objects with Constraint objects 2014-05-24 18:53:30 -07:00
Rafael Mendonça França
ade105be40 Merge pull request #14986 from dlangevin/trailing-slash-url-generation
Fixes URL generation with trailing_slash: true

Conflicts:
	actionpack/lib/action_dispatch/http/url.rb
2014-05-24 12:41:28 -03:00
Aaron Patterson
6d48d97947 glob_param is never used, so rm
this also changes the constructor.  We don't need to pass more options
than "defaults" (whatever defaults are, ugh. probably another hash of
stupid stuff).
2014-05-23 15:25:46 -07:00
Aaron Patterson
0f5e3a9f6b decouple the router object from the request class 2014-05-23 10:57:25 -07:00
Aaron Patterson
6fd8346400 pass the correct custom request to the recognize method 2014-05-23 10:57:25 -07:00
Aaron Patterson
6ed5b01f97 switch to the serve method so we can remove the request class (eventually) 2014-05-23 10:57:25 -07:00
Aaron Patterson
aaceca625d extract request allocation from the main app serving routine 2014-05-23 10:57:25 -07:00
Aaron Patterson
890e0a97fb remove NullRequest and just always pass a request class 2014-05-23 10:09:24 -07:00
Aaron Patterson
a6e94547e8 use the request object since we have it
stop hardcoding hash keys and use the accessors provided on the request
object.
2014-05-23 09:56:33 -07:00
Aaron Patterson
9ca4839a1a stop using PARAMETERS_KEY, and use the accessor on the request object
this decouples our code from the env hash a bit.
2014-05-22 15:57:24 -07:00
Aaron Patterson
925bd97566 use symbol keys for path_parameters 2014-05-22 15:37:56 -07:00
Dan Langevin
82b4d879bf Fixes URL generation with trailing_slash: true
URL generation with trailing_slash: true was adding a trailing slash
after .:format

    Routes.draw do
      resources :bars
    end

    bars_url(trailing_slash: true, format: 'json')
      # => /bars.json/

This commit removes that extra trailing slash
2014-05-22 16:03:52 -04:00
Guo Xiang Tan
4fd144dd4b Form full URI as string to be parsed in Rack::Test.
There are performance gains to be made by avoiding URI setter methods.
2014-05-21 23:17:17 -07:00
Aaron Patterson
dd1f23df7b middle variable is never used, so rm 2014-05-21 16:12:49 -07:00
Aaron Patterson
089d9baa33 we don't use this parameter for anything, so rm 2014-05-20 16:06:59 -07:00
Rafael Mendonça França
ef00bb7196 Merge pull request #11346 from tomykaira/fix_10257
Check authentication scheme in Basic auth
2014-05-20 18:12:13 -03:00
Yves Senn
7591e8c1a7 Merge pull request #15182 from zuhao/refactor_actionpack_respond_with_test_2
Un-define :to_json for Customer class after stubbing.
2014-05-20 08:58:17 +02:00
Zuhao Wan
f0440205f6 Add using_resouce_with_json to controller. 2014-05-20 14:52:06 +08:00
Yves Senn
00d1b132c0 Merge pull request #15178 from zuhao/refactor_actionpack_respond_with_test
Deregister csv renderer after test to prevent leak.
2014-05-20 08:21:32 +02:00
Aaron Patterson
62d1b330c4 Revert "Rewrite journey routes formatter for performance"
This reverts commit 5c224de9e110763ec7a0f01f5b604bcf81f40bfb.

Conflicts:
	actionpack/lib/action_dispatch/journey/visitors.rb

5c224de9e110763ec7a0f01f5b604bcf81f40bfb introduced a bug in the
formatter.  This commit includes a regression test.
2014-05-19 16:14:47 -07:00
Zuhao Wan
ac36b45672 Add ActionController::Renderers.remove. 2014-05-20 02:00:57 +08:00
Jarmo Isotalo
adffea62b5 Upgraded rack
As Rack has some non backwards compatible changes added required
modifications to keep behaviour in rails close to same as before.

Also modified generators to include rack/rack for not yet released
version of rack
2014-05-19 00:03:08 +03:00
Zuhao Wan
45c396bd82 Ensure :js is defined regardless of the outcome of the test. 2014-05-17 19:09:09 +08:00
Christiaan Van den Poel
20fece1491 fixes stack level too deep exception on action named 'status' returning 'head :ok' 2014-05-15 21:14:46 +02:00
kasper
42728c70ee Add RFC4791 MKCALENDAR method 2014-05-15 17:41:37 +03:00
Guo Xiang Tan
30f93dc65e Remove unused method in RouteSet test. 2014-05-15 00:51:55 -07:00
Rafael Mendonça França
f2bff250a0 Merge pull request #14137 from dasch/better-fragment-cache-instrumentation
Add controller and action name to the fragment caching instrumentation payload

Conflicts:
	actionpack/CHANGELOG.md
2014-05-14 20:04:43 -03:00
Aaron Patterson
125cc780c5 Merge pull request #15070 from ayamomiji/sse-patch
Add multiple lines message support for SSE module
2014-05-14 14:02:04 -07:00
Aaron Patterson
348af15c33 _recall should be set to a hash or not set
Then we can avoid nil checks
2014-05-13 17:21:55 -07:00
Arthur Neves
7ec665303d
Fix regression on assert_redirected_to.
`assert_redirected_to` would fail if there is no controller set on
a `ActionDispatch::IntegrationTest`, as _compute_redirect_to_location
would be called on the controller to build the url.

This regression was introduced after 1dacfbabf3bb1e0a9057dd2a016b1804e7fa38c0.

[fixes #14691]
2014-05-13 00:03:38 -04:00
Aaron Patterson
3d9bd2ac94 this class is a model, so it should act like one 2014-05-12 15:54:46 -07:00
ayaya
7a84f0b33d Add multiple lines message support for SSE module 2014-05-12 23:54:03 +08:00
Guo Xiang Tan
da290fae09 Remove unnecessary include for integration tests. 2014-05-11 16:02:12 -07:00
Guo Xiang Tan
77e25a777a Remove redundant tests method. 2014-05-11 15:29:36 -07:00
Andrew White
2378f69e69 Always use the provided port for protocol relative urls
There may be situations where you need to tunnel SSL connections over
port 80 so we shouldn't remove it if it has been explicitly provided.
2014-05-11 12:59:37 +01:00
Guilherme Cavalcanti
be93d94ef2 ActionDispatch::Http::URL.normalize_port should not strip port for protocol relative URL. 2014-05-11 12:59:37 +01:00
Daniel Schierbeck
92fbbf67e3 Add controller and action name to the instrumentation payload 2014-05-10 09:35:29 +00:00
Aaron Patterson
314cbea9a3 just call the method and assert the return value
do not test internals
2014-05-09 12:05:24 -07:00
schneems
ca97ec5099 HTTP::Headers#key? correctly converts
Previously if you were looking for a given key, the header may incorrectly tell you that it did not exist even though it would return a valid value:

```ruby
env     = { "CONTENT_TYPE" => "text/plain" }
headers = ActionDispatch::Http::Headers.new(env)
headers["Content-Type"] 
# => "text/plain"

headers.key?("Content-Type")
# => false
```

This PR fixes that behavior by converting the key before checking for presence
2014-05-07 12:01:34 -05:00
Rafael Mendonça França
2bb008a6cf Merge pull request #14945 from tomkadwill/form_authenticity_param_refactor
Moved 'params[request_forgery_protection_token]' into its own method and...
2014-05-06 14:30:21 -03:00
Rafael Mendonça França
bdcd5f94b2 Only accept actions without File::SEPARATOR in the name.
This will avoid directory traversal in implicit render.

Fixes: CVE-2014-0130

Conflicts:
	actionpack/lib/abstract_controller/base.rb
2014-05-06 13:36:58 -03:00
Tom Kadwill
7d5a858e5c Moved 'params[request_forgery_protection_token]' into its own method and improved tests. 2014-05-06 14:58:30 +01:00
Rafael Mendonça França
5ad661e287 Use assert_raises 2014-05-04 18:47:21 -03:00
Rafael Mendonça França
95ab4fd6b7 Merge pull request #11166 from xavier/callable_constraint_verification
Callable route constraint verification

Conflicts:
	actionpack/CHANGELOG.md
2014-05-04 18:42:20 -03:00
Guo Xiang
1f8933077d Remove tests method for test cases when controller can be inferred. 2014-05-03 23:55:23 -07:00
Rafael Mendonça França
b638c1a0b3 Merge pull request #12651 from cespare/ipv6-remote-ip-fixes
Make remote_ip detection properly handle private IPv6 addresses

Conflicts:
	actionpack/CHANGELOG.md
2014-05-01 14:43:14 -03:00
Earl St Sauver
31c3eec05d Propagate test messages through assert_routing helper, Fixes #14908
assert_routing was not raising the message passed into the assertion
violation that it raised. This change propagates messages through
the on_fail error.

This fixes this error:
https://github.com/rails/rails/issues/14908

A test case for this issue is located here.
https://github.com/estsauver/test14908

To see that test case fail in the example app, just run
ruby -Itest test/controllers/guests_controller_test.rb
2014-04-29 18:34:56 -07:00
Godfrey Chan
2a412b3d6f Fixed an issue with migrating legacy json cookies.
Previously, the `VerifyAndUpgradeLegacySignedMessage` assumes all incoming
cookies are marshal-encoded. This is not the case when `secret_token` is
used in conjunction with the `:json` or `:hybrid` serializer.

In those case, when upgrading to use `secret_key_base`, this would cause a
`TypeError: incompatible marshal file format` and a 500 error for the user.

Fixes #14774.

*Godfrey Chan*
2014-04-23 12:32:14 -05:00
Andrew White
5460591f02 Make URL escaping more consistent
1. Escape '%' characters in URLs - only unescaped data
   should be passed to URL helpers

2. Add an `escape_segment` helper to `Router::Utils`
   that escapes '/' characters

3. Use `escape_segment` rather than `escape_fragment`
   in optimized URL generation

4. Use `escape_segment` rather than `escape_path`
   in URL generation

For point 4 there are two exceptions. Firstly, when a route uses wildcard
segments (e.g. *foo) then we use `escape_path` as the value may contain '/'
characters. This means that wildcard routes can't be optimized. Secondly,
if a `:controller` segment is used in the path then this uses `escape_path`
as the controller may be namespaced.

Fixes #14629, #14636 and #14070.
2014-04-20 10:11:38 +01:00
edogawaconan
e2ef83f838 Always escape string passed to url helper.
Makes it clear that anything passed with the helper must not be percent encoded.

Fixes previous behavior which tricks people into believing passing
non-percent-encoded will generate a proper percent-encoded path while in
reality it doesn't ('%' isn't escaped).

The intention is nice but the heuristic is broken.
2014-04-20 10:11:37 +01:00
Rafael Mendonça França
1de258e6c6 Remove wrapper div for inputs in button_to
Related with cbb917455f306cf5818644b162f22be09f77d4b2
2014-04-17 16:15:43 -03:00
Rafael Mendonça França
dd5f831f3b Update Request forgery tests to remove input wrappign div
This was changed at cbb917455f306cf5818644b162f22be09f77d4b2
2014-04-17 16:14:40 -03:00
Rafael Mendonça França
d1c5e4b28b Change the method description 2014-04-17 14:49:02 -03:00
Rafael Mendonça França
b77d10f6fe Merge pull request #14755 from timlinquist/to_io_http_upload
Use common to_io so users can access the underlying IO object
2014-04-17 14:46:45 -03:00
Tim Linquist
e601728dce Provide interface for accessing underlying IO object
In some cases users may need to work with/manipulate more of the
Tempfile api than provided by Upload. Allow users to get at the
underlying io via the common to_io method of IO/IO-like objects
2014-04-15 11:05:08 -07:00
Rafael Mendonça França
3fce111b3b Merge pull request #14745 from razum2um/plain-text-diagnostics
Display diagnostics in text format for xhr request
2014-04-15 12:51:59 -03:00
Yves Senn
81678075f8 Merge pull request #14728 from stomar/assertion-msg
Remove surplus period from assertion messages
2014-04-15 08:57:43 +02:00
Rafael Mendonça França
4d21e496e1 Return null type format when format is not know
When requesting a controller with the following code with a unknown format:

    def my_action
      respond_to do |format|
        format.json { head :ok }
        format.any { render text: 'Default response' }
      end
    end

we should render the default response instead of raising ActionController::UnknownFormat

Fixes #14462

Conflicts:
	actionpack/CHANGELOG.md
	actionpack/test/controller/mime/respond_with_test.rb

Conflicts:
	actionpack/CHANGELOG.md
2014-04-14 17:10:11 -03:00
Marcus Stollsteimer
ce6f472f28 Refine tests for assert_select failure messages 2014-04-14 17:40:57 +02:00
Vlad Bokov
59dbf68960 Display diagnostics in text format for xhr request 2014-04-14 20:48:13 +07:00
James Coglan
77252c332e Add a failing test for a URL helper that was broken by a6b9ea2. 2014-04-10 13:54:41 +01:00
Andriel Nuernberg
85e424de6c Avoid URI parsing
This parsing is unecessary once the Request object already has the
needed information.
2014-04-09 14:19:53 -03:00
Vipul A M
a44d7107df Remove unused subclass_controller_with_flash_type_bar var from flash test. 2014-04-07 10:34:17 +05:30
Guo Xiang Tan
8bbaa94c81 Fix setup of adding _flash_types test.
Adding flash types to a controller within any of the tests will result
in a global state change of the controller under test.

This patch will prevent state leaks and allow us to run the test in random order.
2014-04-06 13:30:49 -07:00
Boris Kuznetsov
6af07c27ae Append link to bad code to backtrace when exception is SyntaxError 2014-03-27 00:36:59 +04:00
David Heinemeier Hansson
9d44b3f886 Update test helper to use latest Digestor API 2014-03-21 19:39:08 +01:00
Attila Domokos
102c556e0b Cleaning and adding tests for Session
Adding tests for Session `destroy`, `update` and `delete` methods. No changes for code under test.
2014-03-19 21:01:08 -05:00
Aaron Patterson
ba3ad256c6 Merge pull request #14090 from Fortisque/kevin/stream_error_in_main_thread_if_not_committed
re-raise error if error occurs before committing in streaming
2014-03-17 10:49:07 -07:00
Jeremy Kemper
cbc3b89c10 Add an explicit require for 4ece124396669d3580e7f229ab407a0d4882727a rather than assume SecureRandom is available 2014-03-16 16:08:16 -07:00
Jeremy Kemper
4ece124396 Avoid concurrent test collision on the same memcache server by namespacing keys 2014-03-16 16:06:27 -07:00
Andrew White
bb0518891c Use nested_scope? not shallow? to determine whether to copy options
The method `shallow?` returns false if the parent resource is a singleton so
we need to check if we're not inside a nested scope before copying the :path
and :as options to their shallow equivalents.

Fixes #14388.
2014-03-16 09:35:35 +00:00
Kevin Casey
933e9b4fe2 re-raise error if error occurs before committing in streaming
update the tests, using an if-else
2014-03-14 23:54:43 -07:00
Rafael Mendonça França
274d5e45e0 Merge pull request #14329 from pch/digestor-lookup-fix
Ensure LookupContext in Digestor selects correct variant
2014-03-14 14:58:34 -03:00
Łukasz Strzałkowski
f72feae9ba Don't pass variant in params, it's ignored
We're setting variant above, in request object directly
2014-03-13 17:53:11 +01:00
Aaron Patterson
3df07d093a use the body proxy to freeze headers
avoid freezing the headers until the web server has actually read data
from the body proxy.  Once the webserver has read data, then we should
throw an error if someone tries to set a header
2014-03-12 17:40:08 -07:00
Aaron Patterson
77a09218f6 only write the jar if the response isn't committed
when streaming responses, we need to make sure the cookie jar is written
to the headers before returning up the stack. This commit introduces a
new method on the response object that writes the cookie jar to the
headers as the response is committed.  The middleware and test framework
will not write the cookie headers if the response has already been
committed.

fixes #14352
2014-03-12 16:07:26 -07:00
Piotr Chmolowski
025c691536 Ensure LookupContext in Digestor selects correct variant
Related to: #14242 #14243 14293

Variants passed to LookupContext#find() seem to be ignored, so
I've used the setter instead: `finder.variants = [ variant ]`.

I've also added some more test cases for variants. Hopefully this
time passing tests will mean it actually works.
2014-03-09 08:47:17 +01:00
Andrew White
af4c9b78ff Copy shallow options from normal options when using scope
If the options :shallow_prefix and :shallow_path are not set in the
scope options then copy them from the normal :as and :path options
if they are set.
2014-03-08 19:51:06 +00:00
Andrew White
8711086f5a Pull namespace defaults out of the options hash
If a developer has specified either :path or :as in the options hash then
these should be used as the defaults for :shallow_path and :shallow_prefix.

Fixes #14241.
2014-03-08 19:51:06 +00:00
Andrew White
dcc91a04a1 Only use shallow nested scope when depth is > 1
By tracking the depth of resource nesting we can push the need for nested
shallow scoping to only those routes that are nested more than one deep.
This allows us to keep the fix for #12498 and fix the regression in #14224.

Fixes #14224.
2014-03-08 19:51:06 +00:00
Santiago Pastorino
2af7a7b19c Merge pull request #14280 from joho/make_csrf_failure_logging_optional
Make CSRF failure logging optional/configurable.
2014-03-08 15:22:42 -02:00
Prem Sichanugrist
ed88a601f7
Do note remove Content-Type when render :body
`render :body` should just not set the `Content-Type` header. By
removing the header, it breaks the compatibility with other parts.

After this commit, `render :body` will returns `text/html` content type,
sets by default from `ActionDispatch::Response`, and it will preserve
the overridden content type if you override it.

Fixes #14197, #14238

This partially reverts commit 3047376870d4a7adc7ff15c3cb4852e073c8f1da.
2014-03-05 10:33:52 -05:00
John Barton (joho)
67584c6ae3 Make CSRF failure logging optional/configurable.
Added the log_warning_on_csrf_failure option to ActionController::RequestForgeryProtection
which is on by default.
2014-03-05 11:31:57 +11:00
Piotr Chmolowski
1858cc6070 Variants in ActionView::Digestor
Take variants into account when calculating template digests in
ActionView::Digest.

Digestor#digest now takes a hash as an argument to support variants and
allow more flexibility in the future. Old-style arguments have been
deprecated.

Fixes #14242
2014-03-04 15:02:58 +01:00
Zachary Scott
11e815e938 Refactor tests from BaseRackTest into BaseRequestTest 2014-03-01 15:38:47 -08:00
Aaron Patterson
401787db4b make sure we wait for the threads to shut down before asserting closure 2014-02-28 16:35:33 -08:00
Aaron Patterson
a7b059ec7f use built-in exception handling in live controllers
when an exception happens in an action before the response has been
committed, then we should re-raise the exception in the main thread.
This lets us reuse the existing exception handling.
2014-02-28 15:39:08 -08:00
Aaron Patterson
30d21dfcb7 live controllers should have live responses
detect the type of controller we're testing and return the right type of
response based on that controller.  This allows us to stop doing the
weird sleep thing.
2014-02-28 15:22:43 -08:00
Aaron Patterson
9af4258186 set the error callback to a nice default in case nobody set an error callback and an error happens 2014-02-28 11:57:15 -08:00
Tony Wooster
a351149e80 Fix controller test not resetting @_url_options
Commit 4f2cd3e9 introduced a bug by reordering the call to
`@controller.recycle!` above the call to `build_request_uri`. The
impact of this was that the `@_url_options` cache ends up not being
reset between building a request URI (occurring within the test
controller) and the firing of the actual request.

We encountered this bug because we had the following setup:

  class MinimumReproducibleController < ActionController::Base
    before_filter { @param = 'param' }

    def index
      render text: url_for(params)
    end

    def default_url_options
      { custom_opt: @param }
    end
  end

  def test_index
    get :index # builds url, then fires actual request
  end

The first step in  `get :index` in the test suite would populate the
@_url_options cache. The subsequent call to `url_for` inside of the
controller action would then utilize the uncleared cache, thus never
calling the now-updated default_url_options.

This commit fixes this bug calling recycle! twice, and removes a call
to set response_body, which should no longer be needed since we're
recycling the request object explicitly.
2014-02-26 10:39:44 -08:00
Serj L
88cfeca16a Simple Sungularize ActionController::UnpermittedParameters error in case when only 1 parameter is unpermitted. 2014-02-24 13:25:38 +04:00
Prem Sichanugrist
3047376870 Add #no_content_type attribute to AD::Response
Setting this attribute to `true` will remove the content type header
from the request. This is use in `render :body` feature.
2014-02-18 12:11:41 -05:00
Prem Sichanugrist
920f3ba266 Introduce render :html for render HTML string
This is an option for to HTML content with a content type of
`text/html`. This rendering option calls `ERB::Util.html_escape`
internally to escape unsafe HTML string, so you will have to mark your
string as html safe if you have any HTML tag in it.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Prem Sichanugrist
8cd9f6d205 Introduce render :plain for render plain text
This is as an option to render content with a content type of
`text/plain`. This is the preferred option if you are planning to render
a plain text content.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Prem Sichanugrist
9e9cc66077 Update hash format for render_text_test 2014-02-18 12:08:36 -05:00
Prem Sichanugrist
103e18c87d Introduce render :body for render raw content
This is an option for sending a raw content back to browser. Note that
this rendering option will unset the default content type and does not
include "Content-Type" header back in the response.

You should only use this option if you are expecting the "Content-Type"
header to not be set. More information on "Content-Type" header can be
found on RFC 2616, section 7.2.1.

Please see #12374 for more detail.
2014-02-18 12:08:36 -05:00
Kevin Casey
8508346dd0 Correct prestreaming controller response status.
if the controller action has not yet streamed any data, actions should
process as normal, and errors should trigger the appropriate behavior
(500, or in the case of ActionController::BadRequest, a 400 Bad Request)
2014-02-15 13:05:00 -08:00
David Heinemeier Hansson
bfc34fc005 No variant should also be picked up by variant.any if variant.none is not defined (just like any other variant) 2014-02-13 20:44:10 +01:00
Łukasz Strzałkowski
00a4af9ab7 Check if variant array contains only symbols 2014-02-13 18:05:55 +01:00
Lukasz Strzalkowski
f9b6b865e6 Variant negotiation
Allow setting `request.variant` as an array - an order in which they will be
rendered.

For example:

  request.variant = [:tablet, :phone]

  respond_to do |format|
    format.html.none
    format.html.phone # this gets rendered
  end
2014-02-13 16:22:56 +01:00
Godfrey Chan
b97e087321 Fixed broken flash tests 2014-02-11 01:54:17 -08:00
Godfrey Chan
ead947a3b2 Re-write legacy (marshal) cookies on read 2014-02-11 01:54:17 -08:00
Guillermo Iguaran
a6ce984b49 Convert FlashHash in a Hash with indifferent access 2014-02-11 01:54:17 -08:00
Godfrey Chan
ba6861d032 Changed the tests to ensure HybridSerializer actually migrates the cookies (currently failing) 2014-02-11 01:54:17 -08:00
Godfrey Chan
6de4888e04 Fixed minor typo in test code 2014-02-11 01:54:17 -08:00
Rafael Mendonça França
d4b7aa735a Tests for the HybridSerializer 2014-02-11 01:54:17 -08:00
Godfrey Chan
25f68ac6a2 Removed an old test 2014-02-11 01:54:17 -08:00
Godfrey Chan
54641fa2e3 Just very so slightly better test coverage 2014-02-11 01:54:16 -08:00
Godfrey Chan
b927d67dec Renamed session_serializer option to cookies_serializer 2014-02-11 01:54:16 -08:00
Yves Senn
3b868cc99d docs, link to HTTP and CGI header definitions. [ci skip]
This was a reaction to: https://github.com/rails/rails/pull/9700#issuecomment-34550210
2014-02-10 15:51:51 +01:00
Andrew White
462d7cb314 Set the :shallow_path as each scope is generated
If we set :shallow_path when shallow is called it can result in incorrect
paths if the resource is inside a namespace because namespace itself sets
the :shallow_path option to the namespace path.

We fix this by removing the :shallow_path option from shallow as that should
only be turning shallow routes on and not otherwise affecting the scope.
To do this we need to treat the :shallow option to resources differently to
other scope options and move it to before the nested block is called.

This change also has the positive side effect of making the behavior of the
:shallow option consistent with the shallow method.

Fixes #12498.
2014-02-09 10:46:07 -08:00
Aaron Patterson
33be58b206 Merge pull request #13982 from dskang/fix-response-flatten-infinite-recursion
Fix response flatten infinite recursion
2014-02-09 08:50:28 -08:00
Carlos Antonio da Silva
e08514e822 Merge pull request #13985 from zzak/remove_old_todo_in_url_for_test
Remove outdated TODO from url_for test, this test was fixed in 900a2d30
2014-02-09 11:49:18 -02:00
SHIBATA Hiroshi
a09c07890a use File.exist? instead of File.exists? 2014-02-09 17:39:55 +09:00
Dan Kang
069bc27385 Prevent [response].flatten from recursing infinitely.
Returning `self` from within the array returned by `to_ary`
caused this. Instead, we can just substitute another object.
It provides the `each` behavior required by the rack spec.
2014-02-08 23:22:04 -08:00
Zachary Scott
dfe9cf1ace Remove outdated TODO from url_for test, this test was fixed in 900a2d30 2014-02-09 04:20:56 +02:00
Myron Marston
cbd10e27d1 Add missing test for response destructuring. 2014-02-08 17:40:28 -08:00
Mikko Johansson
ccd1c435ee Skips tests on Windows that create files with illegal characters 2014-02-09 02:02:44 +02:00
Ionatan Wiznia
f8d740af93 Tests that skips a controller filters that was set up using a class 2014-02-06 20:11:40 +01:00
Rafael Mendonça França
e9be1c1e80 Merge pull request #13863 from joshjordan/jsj-dont-throw-out-get-params
Do not discard query parameters on requests that use wrap_parameters

Conflicts:
	actionpack/CHANGELOG.md
2014-02-01 15:53:27 -02:00
Josh Jordan
1f9586fd47 Do not discard query parameters on requests that use wrap_parameters 2014-01-30 18:20:55 -05:00
Guillermo Iguaran
fd487860db Modify the session serializer implementation
Rename allowed options to :marshal and :json, for custom serializers
only allow the use of custom classes.
2014-01-30 01:53:19 -05:00
Lukasz Sarnacki
b23ffd0dac Allow session serializer key in config.session_store
MessageEncryptor has :serializer option, where any serializer object can
be passed. This commit make it possible to set this serializer from configuration
level.

There are predefined serializers (:marshal_serializer, :json_serialzier)
and custom serializer can be passed as String, Symbol (camelized and
constantized in ActionDispatch::Session namepspace) or serializer object.

Default :json_serializer was also added to generators to provide secure
defalt.
2014-01-29 17:05:00 +01:00
Andrew White
3161606803 Clear filtered request attributes between requests in tests
The request attributes filtered_parameters, filtered_env and filtered_path
are memoized for performance reasons. However this can cause unusual
behavior in tests where there are multiple calls to get, post, etc.

Fixes #13803.
2014-01-27 13:30:28 +00:00
Andrew White
a31a44a266 Add additional tests for #13824 2014-01-25 07:38:29 +00:00
Byron Bischoff
345555cd4c Transform dashes to underscores in resource route names
Fixes #13824
2014-01-25 07:19:33 +00:00
Francesco Rodriguez
e2f3e0dc50 Remove unused argument. 2014-01-24 22:25:15 -03:00
Yves Senn
8efd5fec75 Merge pull request #13811 from mdesantis/issue-13810
Fixes #13810 `rake routes` error when mount `Rails::Engine` with empty routes
2014-01-24 04:34:22 -08:00
Maurizio De Santis
c1f8a0d614 Fix rake routes error when Rails::Engine with empty routes is mounted; fixes rails/rails#13810
Squash
2014-01-24 12:41:48 +01:00
Guillermo Iguaran
f1a0b15139 Merge pull request #13819 from arthurnn/one_require_test
unify param.require tests
2014-01-23 19:33:59 -08:00
Arthur Neves
aae53d2175 unify param.require tests 2014-01-23 22:28:24 -05:00
Arthur Neves
96dd3016d1 test boolean and number json param parsing 2014-01-23 21:56:28 -05:00
Andrew White
bf191318af Tidy up tests and CHANGELOG for #12598 2014-01-20 16:34:22 +00:00
Mikko Johansson
f9f32e04ad Automatically convert dashes to underscores in shorthand routes 2014-01-20 15:37:23 +00:00
Amr Tamimi
746abbcc31 Automatically convert dashes to underscores for url helpers 2014-01-20 15:24:30 +00:00
Piotr Sarnacki
2e0f9ed76e Revert "Don't remove trailing slash from PATH_INFO for mounted apps"
The revert is needed because of a regression described in #13369, routes
with trailing slash are no longer recognized properly.

This reverts commit 50311f1391ddd8e0349d74eb57f04b7e0045a27d.
2014-01-16 10:13:51 +01:00