Commit Graph

11713 Commits

Author SHA1 Message Date
Jeremy Kemper
79d50ce310 Merge pull request #16570 from bradleybuda/breach-mitigation-mask-csrf-token
CSRF token mask from breach-mitigation-rails gem
2014-08-19 18:17:07 -07:00
Bradley Buda
69fc0e1b5e Auth token mask from breach-mitigation-rails gem
This merges in the code from the breach-mitigation-rails gem that masks
authenticity tokens on each request by XORing them with a random set of
bytes. The masking is used to make it impossible for an attacker to
steal a CSRF token from an SSL session by using techniques like the
BREACH attack.

The patch is pretty simple - I've copied over the [relevant
code](https://github.com/meldium/breach-mitigation-rails/blob/master/lib/breach_mitigation/masking_secrets.rb)
and updated the tests to pass, mostly by adjusting stubs and mocks.
2014-08-19 15:28:07 -07:00
Rafael Mendonça França
08f209614b Use released rails-deprecated_sanitizer 2014-08-19 16:45:31 -03:00
Rafael Mendonça França
fad9e729f1 Fix the rails-dom-testing dependecy 2014-08-19 16:41:38 -03:00
Rafael Mendonça França
d59a24d543 Protect against error when parsing parameters with Bad Request
Related with #11795.
2014-08-19 15:36:05 -03:00
Jeremy Kemper
4d1d81d338 Merge pull request #16299 from sikachu/ps-safer-ac-params
Update `ActionController::Parameters` to be more secure on parameters handling
2014-08-19 11:31:38 -07:00
Vijay Dev
41231ef6c6 Merge branch 'master' of github.com:rails/docrails
Conflicts:
	actionpack/lib/action_controller/metal/mime_responds.rb
	actionview/lib/action_view/vendor/html-scanner/html/sanitizer.rb
	activerecord/lib/active_record/type/value.rb
2014-08-19 16:28:53 +00:00
Godfrey Chan
0d4d52a1cf Add missing require 2014-08-18 21:33:00 -07:00
Prem Sichanugrist
3fcbbc8a1c User #to_hash instead of calling super
Ruby 1.9.3 does not implement Hash#to_h, so we can't call `super` on it.
2014-08-18 23:42:42 -04:00
Prem Sichanugrist
3591dd59e0 Fix failing test on several methods on Parameter
* `each`
* `each_pair`
* `delete`
* `select!`
2014-08-18 20:42:46 -04:00
Prem Sichanugrist
0663e8f179 Seperate Parameters accessors and mutators tests 2014-08-18 20:42:46 -04:00
Prem Sichanugrist
9704379c78 Refactor code to reduce duplicate self.class.new 2014-08-18 20:42:45 -04:00
Prem Sichanugrist
bd7f47190e Add missing Hash methods to AC::Parameters
This is to make sure that `permitted` status is maintained on the
resulting object.

I found these methods that needs to be redefined by looking for
`self.class.new` in the code.

* extract!
* transform_keys
* transform_values
2014-08-18 20:42:45 -04:00
Prem Sichanugrist
5109740c6b Make AC::Params#to_h return Hash with safe keys
`ActionController::Parameters#to_h` now returns a `Hash` with
unpermitted keys removed. This change is to reflect on a security
concern where some method performed on an `ActionController::Parameters`
may yield a `Hash` object which does not maintain `permitted?` status.
If you would like to get a `Hash` with all the keys intact, duplicate
and mark it as permitted before calling `#to_h`.

    params = ActionController::Parameters.new(name: 'Senjougahara Hitagi')
    params.to_h # => {}

    unsafe_params = params.dup.permit!
    unsafe_params.to_h # => {"name"=>"Senjougahara Hitagi"}

    safe_params = params.permit(:name)
    safe_params.to_h # => {"name"=>"Senjougahara Hitagi"}

This change is consider a stopgap as we cannot chage the code to stop
`ActionController::Parameters` to inherit from
`HashWithIndifferentAccess` in the next minor release.

Also, adding a CHANGELOG entry to mention that
`ActionController::Parameters` will not inheriting from
`HashWithIndifferentAccess` in the next major version.
2014-08-18 20:42:45 -04:00
Rafael Mendonça França
9cb4d3e03b Deprecate TagAssertion instead of removing 2014-08-18 20:20:41 -03:00
Santiago Pastorino
6b32a4f371 Bump rack dependency 2014-08-18 16:10:58 -03:00
Akira Matsuda
b30b99c615 Expectations first 2014-08-18 15:40:53 +09:00
Rafael Mendonça França
d2d809868c Merge pull request #15889 from carnesmedia/model-name
Use #model_name on instances instead of classes
2014-08-17 23:01:13 -03:00
Rafael Mendonça França
cdc00aba62 Merge branch 'loofah'
Conflicts:
	Gemfile
2014-08-17 22:51:13 -03:00
Rafael Mendonça França
37a298db39 Merge pull request #16533 from lucasmazza/lm-named-routes-helper
Deprecate NamedRouteCollection#helpers.
2014-08-17 22:47:52 -03:00
Rafael Mendonça França
c78da4d5c4 Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
2014-08-17 22:38:22 -03:00
Lucas Mazza
9ee64f07f7 Deprecate NamedRouteCollection#helpers.
This method was removed at 210b338db20b1cdd0684f40bd78b52ed16148b99 but it is
used by third party gems to check if a named route was defined. To help on the
upgrade path on 4.2.0 we bring it back and emit a deprecation warning.
2014-08-17 22:36:22 -03:00
Rafael Mendonça França
eced6f8118 Merge pull request #16294 from bf4/code_tools
Update, unify, encapsulate, and fix various code tools in Rails
2014-08-17 22:12:23 -03:00
Godfrey Chan
e158ee50e6 Use AS::JSON for (de)serializing cookies
Use the Active Support JSON encoder for cookie jars using the `:json` or
`:hybrid` serializer. This allows you to serialize custom Ruby objects into
cookies by defining the `#as_json` hook on such objects.

Fixes #16520.
2014-08-17 12:41:42 -07:00
Godfrey Chan
a485633b16 responders 1.x won't do it. Told you to RTFM for details! 2014-08-17 12:19:23 -07:00
Godfrey Chan
b662273df3 The gem is called 'responders' 2014-08-17 11:58:17 -07:00
Godfrey Chan
24226c51f0 Raise a more helpful error for people who are using these extracted features 2014-08-17 11:54:09 -07:00
Godfrey Chan
69ed422a9c Fixed broken reference caused by 14965ba 2014-08-17 11:44:31 -07:00
Godfrey Chan
beff925c32 Merge pull request #16467 from strzalek/cookies-digest-config-option2
Cookies digest config option (pt. 2)

Conflicts:
	actionpack/CHANGELOG.md
	actionpack/lib/action_dispatch/middleware/cookies.rb
2014-08-17 11:23:14 -07:00
Godfrey Chan
14965baa09 Merge pull request #16484 from strzalek/remove-redundant-null-serializer
Remove redundant NullSerializer
2014-08-17 11:07:00 -07:00
Kasper Timm Hansen
1e2ffe7ae6 Prepare for partial release.
- Default to Rails::DeprecatedSanitizer in ActionView::Helpers::SanitizeHelper.
- Add upgrade notes.
- Add sanitizer to new applications Gemfiles.
- Remove 'rails-dom-testing' as a dependency.
2014-08-17 19:25:47 +02:00
José Valim
57f5b00ba4 Remove more references to respond_with 2014-08-17 13:20:23 -04:00
José Valim
ee77770d57 Move respond_with to the responders gem
respond_with (and consequently the class-level respond_to)
are being removed from Rails. Instead of moving it to a 3rd
library, the functionality will be moved to responders gem
(at github.com/plataformatec/responders) which already provides
some responders extensions.
2014-08-17 13:20:22 -04:00
Jeremy Kemper
6c96602bc1 When your templates change, browser caches bust automatically.
New default: the template digest is automatically included in your ETags.
When you call `fresh_when @post`, the digest for `posts/show.html.erb`
is mixed in so future changes to the HTML will blow HTTP caches for you.
This makes it easy to HTTP-cache many more of your actions.

If you render a different template, you can now pass the `:template`
option to include its digest instead:

  fresh_when @post, template: 'widgets/show'

Pass `template: false` to skip the lookup. To turn this off entirely, set:

  config.action_controller.etag_with_template_digest = false
2014-08-17 06:52:17 -07:00
Aaron Patterson
6c51cc85da extract methods and metaprogram less. 2014-08-14 10:23:28 -07:00
Yves Senn
a1ddde15ae remove deprecated MissingHelperError proxy.
The error was moved outside of the `ClassMethods` module.
2014-08-14 09:37:21 +02:00
Yves Senn
9c91c168ab Merge pull request #16027 from tgxworld/template_assertions
Fixes to ActionController::TemplateAssertions
2014-08-14 08:38:35 +02:00
Aaron Patterson
43ce6e22b1 ask the scope object if it is a resource_method_scope 2014-08-13 19:47:26 -07:00
Aaron Patterson
e4cb3819df ask the scope for the action name 2014-08-13 19:44:05 -07:00
Aaron Patterson
374d66be3e reduce calls to scope_level
this will help us to encapsulate magical symbols so hopefully we can
eliminate hardcoded magic symbols
2014-08-13 19:40:57 -07:00
Aaron Patterson
047af8dd3c change to attr_reader 2014-08-13 19:30:47 -07:00
Aaron Patterson
677bc212eb scope_level is no longer a hash key, just use the ivar 2014-08-13 19:30:47 -07:00
Aaron Patterson
19bb6770c0 move the scope level key fully inside the scope object 2014-08-13 19:30:46 -07:00
Aaron Patterson
911ef972a5 move scope_level to a method on the scope object
now we don't have to have a hard coded key
2014-08-13 19:30:46 -07:00
Aaron Patterson
0127f02826 only look up scope level once
avoid hash lookups and remove depency on the instance
2014-08-13 19:13:58 -07:00
Aaron Patterson
91608dc342 only test prefix once
we don't need to repeat if statements
2014-08-13 18:47:16 -07:00
Aaron Patterson
318eea062e pass consistent parameters to canonical_action?
now we only have to look up @scope[:scope_level] once per call to
canonical_action? and we don't have a variable named "flag"
2014-08-13 18:42:26 -07:00
Aaron Patterson
3b908cba28 fewer operations on the options hash
since we pass `as` down, then we won't have to do an insert / delete
dance with the options hash
2014-08-13 18:34:21 -07:00
Aaron Patterson
d4981c393b this should be accessing the hash, not calling a method 2014-08-13 14:31:55 -07:00
Aaron Patterson
efb835c9c0 UnexpectedErrors may reference exceptions that can't be dumped
UnexpectedError exceptions wrap the original exception, and the original
exception may contain a reference to something that can't be marshal
dumped which will cause the process to die.
2014-08-13 14:22:49 -07:00
Łukasz Strzałkowski
1a6ca03aec Remove redundant NullSerializer
Use one from ActiveSupport::MessageEncryptor module.
2014-08-13 23:09:19 +02:00
Guo Xiang Tan
b1ba333ea7 Fix assert_template for files.
The test was not failing for `assert_template file: nil` when a file
has been rendered.
2014-08-14 00:03:32 +08:00
Aditya Kapoor
2c8714568b [ci skip] correct default cache store class 2014-08-13 18:56:03 +05:30
Yves Senn
80cee184ac Merge pull request #16491 from akshay-vishnoi/doc-changes
[ci skip] fix spelling of overridden
2014-08-13 14:42:51 +02:00
Akira Matsuda
bc116a55ca AM, AP, AV, and AMo tests are already order_independent! 2014-08-13 21:25:10 +09:00
Akshay Vishnoi
12ce5b1cf6 [ci skip] fix spelling of override 2014-08-13 16:47:28 +05:30
Łukasz Strzałkowski
29be3f5d83 Add config option for cookies digest
You can now configure custom digest for cookies in the same way as `serializer`:

  config.action_dispatch.cookies_digest = 'SHA256'
2014-08-12 21:57:51 +02:00
Rafael Mendonça França
a2400308ea Merge branch 'master' into loofah
Conflicts:
	actionpack/CHANGELOG.md
	actionpack/test/controller/integration_test.rb
	actionview/CHANGELOG.md
2014-08-12 11:10:42 -03:00
Rafael Mendonça França
cee28d0120 Merge pull request #16476 from akshay-vishnoi/doc-changes
[ci skip] use "based on" or "based off of"
2014-08-12 10:58:00 -03:00
Rafael Mendonça França
e81f3c210e Nobody sucks so nobody should call this awful method name 2014-08-12 10:51:41 -03:00
Akshay Vishnoi
51a759a745 use 'based on' instead of 'based off' [ci skip] 2014-08-12 18:40:14 +05:30
Akira Matsuda
6ffb29d24e users_dont_suck_but_only_we_suck_and_only_our_tests_are_order_dependent!
Calling ActiveSupport::TestCase.i_suck_and_my_tests_are_order_dependent! in AS::TestCase makes
everyone's tests order dependent, which should never be done by the framework.
2014-08-12 19:37:04 +09:00
Santiago Pastorino
9c6c5aa929 Merge pull request #16440 from tgxworld/pass_log_in_block
Pass block for logging.
2014-08-09 10:42:45 -03:00
Guo Xiang Tan
bc53543cb3 Pass block for logging.
This follows the good practice listed on http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance.
2014-08-09 13:47:24 +08:00
Hendy Tanata
71c7fd1013 Uppercase HTML in docs.
[skip ci]
2014-08-08 14:27:05 -07:00
Santiago Pastorino
d70ba48c4d Revert "Merge pull request #16434 from strzalek/cookies-digest-config-option"
This reverts commit 705977620539e2be6548027042f33175ebdc2505, reversing
changes made to dde91e9bf5ab246f0f684b40288b272f4ba9a699.

IT BROKE THE BUILD!!!
2014-08-08 18:20:33 -03:00
Łukasz Strzałkowski
cfbedd3479 Add config option for cookies digest
You can now configure custom digest for cookies in the same way as `serializer`:

config.action_dispatch.cookies_digest = \SHA256'
2014-08-08 21:20:27 +02:00
Guillermo Iguaran
c69e21d36b Merge pull request #16427 from ryandao/full_stack_source_extract
Full stack source extract
2014-08-08 10:00:18 -05:00
Ryan Dao
28595e0128 Update actionpack CHANGELOG 2014-08-08 15:04:55 +07:00
Ryan Dao
1ed264bc60 Retrieve source code for the entire stack trace
Provide the ability to extract the source code of the entire exception stack
trace, not just the frame raising the error. This improves debugging
capability of the error page, especially for framework-related errors.
2014-08-08 15:04:55 +07:00
Guo Xiang Tan
aaef6a3860 Fixes to TestCaseTest. 2014-08-08 12:29:52 +08:00
Guo Xiang Tan
4c30b4fc21 Fix spelling. 2014-08-07 17:26:56 +02:00
Guo Xiang Tan
14508aec70 Remove ActionController::RaiseActionExceptions.
The latest modification to the code was done in https://github.com/rails/rails/commit/5e3517ea. In Rails 3.2,
`ActionController#rescue_action` was deprecated and `rescue_action_without_handler` is no longer being used.
2014-08-07 17:43:36 +08:00
Aaron Patterson
2090615d39 refactor Redirecting so we do not need a controller instance 2014-08-06 14:17:57 -07:00
Aaron Patterson
acb371ca3f call the routes method on engines
if we access the instance, we can free up lots of codes
2014-08-05 16:50:50 -07:00
Aaron Patterson
9a36fac810 a rails application should be an engine subclass 2014-08-05 16:30:08 -07:00
Aaron Patterson
70673759a0 no reason to lazily instantiate the routes
especially if you're just going to add a call two lines down that
populates the cache. common.
2014-08-05 16:28:55 -07:00
schneems
a9a6423fd6 [ci skip] Document ActionDispatch::Static 2014-08-05 12:17:03 -05:00
schneems
658b40e207 [ci skip] document ActionDispatch::FileHandler 2014-08-05 12:16:46 -05:00
Aaron Patterson
ed180eea48 just assign the instance variables on the test 2014-08-05 09:51:47 -07:00
schneems
e460e7cac0 [ci skip] Document PublicExceptions middleware 2014-08-05 11:45:44 -05:00
Aaron Patterson
3300fdedc7 avoid testing only_path
we know that this call only wants the path returned, so lets call a
method that returns the path.
2014-08-04 18:20:07 -07:00
Santiago Pastorino
930110b045 Regenerate sid when sbdy tries to fixate the session
Fixed broken test.

Thanks Stephen Richards for reporting.
2014-08-04 11:33:19 -03:00
Jack Danger Canty
0b8f35dd9c Using no_result_var in Journey's parser generator
Previously the generated parser had an intermediate local variable
`result` that really useful if you're building up a stateful object but
Journey always discards the result argument to the reduce functions.

This produces a simpler parser for anybody who actually wants to read
the thing.

Sadly, there's no real performance speedup with this change.
2014-08-03 15:23:56 -07:00
Vijay Dev
3bf2a4c0d2 Merge branch 'master' of github.com:rails/docrails
Conflicts:
	guides/source/testing.md
2014-08-02 12:09:07 +00:00
Vijay Dev
d9bd75a0d8 copy edits[ci skip] 2014-08-02 12:05:26 +00:00
Aaron Patterson
ea7fc2e7c0 just set the host, no need for another hash allocation / merge! 2014-08-01 11:55:47 -07:00
Aaron Patterson
8cbcd19d70 always return a string from find_script_name
this allows us to avoid nil checks on the return value
2014-08-01 11:45:59 -07:00
Aaron Patterson
e9bbe4a106 use get instead of accessing the named routes internals 2014-07-31 15:26:53 -07:00
Aaron Patterson
ed9b23d898 invert check so we fail faster
there's no reason to to_sym the string if it doesn't match the regexp
anyway
2014-07-31 11:25:01 -07:00
Aaron Patterson
3e9158bb95 do a hash lookup for collision detection
hash lookup should be faster than searching an array.
2014-07-31 11:22:05 -07:00
Carlos Antonio da Silva
ddb0d4bec1 Realign assignments ✂️ 2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
0b859dfefe Do not reassign variable when mutation is happening
These methods mutate the path variable/argument so there is no need
to reassign it every time.
2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
091a59301f Only concatenate path if it was given rather than converting blindly 2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
fafff357cc Rename variable to better show its intent 2014-07-31 13:24:17 -03:00
Carlos Antonio da Silva
277247110c Simplify conditional 2014-07-31 13:24:16 -03:00
Carlos Antonio da Silva
8d61463f34 Push options check up so we can simplify internal methods 2014-07-31 13:24:16 -03:00
Carlos Antonio da Silva
dccdee7e2d Simplify code branch, remove #tap 2014-07-31 09:47:46 -03:00
Carlos Antonio da Silva
a9c0eb4392 Avoid a new hash object 2014-07-31 09:43:02 -03:00
Carlos Antonio da Silva
d97ba0d31b Remove unnecessary call to #tap
This is not storying the RouteSet instance anywhere as the other
examples in the file, so no need to use #tap.
2014-07-31 08:10:37 -03:00
Aaron Patterson
3429b0ccba remove useless deup
every call to default_resources_path_names allocates a new hash, no need
to dup
2014-07-30 18:11:24 -07:00
Aaron Patterson
20ec0d2aae push options inside the scope object 2014-07-30 17:20:37 -07:00
Aaron Patterson
dc3f25c8a5 turn scope in to a linked list
this makes scope rollback much easier
2014-07-30 17:19:00 -07:00
Aaron Patterson
68aea29cf5 remove alias_method_chain
we can `super` in to the previous implementation.
2014-07-30 14:53:28 -07:00
Aaron Patterson
09603275e9 avoid instrospection on the module
we already know what helpers are path helpers, so just iterate through
that list and define the helpers with warnings
2014-07-30 14:51:28 -07:00
Aaron Patterson
d9108abcad fix variable name 2014-07-30 14:46:45 -07:00
Aaron Patterson
210b338db2 split path_helpers and url_helpers
this lets us avoid hard coding a regexp for separating path and url
helpers in the clear! method.
2014-07-30 14:46:07 -07:00
Aaron Patterson
cf6658c284 add will remove the method if it exists already 2014-07-30 14:38:50 -07:00
@schneems and @sgrif
2bbcca004c Deprecate *_path methods in mailers
Email does not support relative links since there is no implicit host. Therefore all links inside of emails must be fully qualified URLs. All path helpers are now deprecated. When removed, the error will give early indication to developers to use `*_url` methods instead.

Currently if a developer uses a `*_path` helper, their tests and `mail_view` will not catch the mistake. The only way to see the error is by sending emails in production. Preventing sending out emails with non-working path's is the desired end goal of this PR.

Currently path helpers are mixed-in to controllers (the ActionMailer::Base acts as a controller). All `*_url` and `*_path` helpers are made available through the same module. This PR separates this behavior into two modules so we can extend the `*_path` methods to add a Deprecation to them. Once deprecated we can use this same area to raise a NoMethodError and add an informative message directing the developer to use `*_url` instead.

The module with warnings is only mixed in when a controller returns false from the newly added `supports_relative_path?`.

Paired @sgrif & @schneems
2014-07-30 12:01:45 -05:00
Santiago Pastorino
4efb36e7b4 Revert "Merge pull request #15305 from tgxworld/remove_unnecessary_require"
This reverts commit f632f79b8dcd144408c66a544984b2ba9cf52f87, reversing
changes made to 98c7fe87690ca4de6c46e8f69806e82e3f8af42d.

Closes #16343
2014-07-30 09:46:33 -03:00
Aaron Patterson
d7b726be00 oops! 💣
use helpers.include? so we don't get any false positives
2014-07-29 12:18:21 -07:00
Aaron Patterson
f889831ed6 ask the named routes collection if the route is defined
we should not be accessing internals to figure out if a method is
defined.
2014-07-29 12:15:04 -07:00
Aaron Patterson
0088b08dca helpers should be a Set so it doesn't grow unbounded
since helpers is a set, we can be confident about when to remove methods
from the module.
2014-07-29 11:48:14 -07:00
Aaron Patterson
41931b8af1 pass the module to define_named_route_methods
after this, we can disconnect @module from the instance
2014-07-29 11:32:17 -07:00
Aaron Patterson
a2e926698d only ask for the routes module once
we can cache the module on the stack, then reuse it
2014-07-29 11:28:45 -07:00
Aaron Patterson
d2d3376903 eval_block should be private 2014-07-29 11:07:43 -07:00
Aaron Patterson
9f63a78d55 remove the mounted? method
we know the routes should not be "optimized" when mounting an
application
2014-07-28 14:07:53 -07:00
Aaron Patterson
099fd0efc4 remove some caching
this caching doesn't increase performance, but does increase complexity.
remove it for now and find better ways to speed up this code.
2014-07-28 13:57:05 -07:00
Yves Senn
171818c60c Merge pull request #16303 from rajcybage/removing_master
remove empty unused method
2014-07-28 17:22:53 +02:00
David Albert
dce49f83c8 Fix protect_from_forgery docs 2014-07-27 13:20:58 -04:00
Rajarshi Das
f6a52f1e9d add comment to the empty each method for not removing it in future 2014-07-26 20:05:31 +05:30
Benjamin Fleischer
91d199259b Encapsulate rake lines from ActiveRecord/ActionPack as CodeTools::LineStatistics
[ci skip]
2014-07-25 13:41:18 -05:00
Yves Senn
6d87b78ab3 docs, add ref where to find valid head status symbols.
[ci skip]
2014-07-25 15:31:24 +02:00
Guo Xiang Tan
e6f2d4f685 Improve description of tests. 2014-07-25 00:43:45 +08:00
Guo Xiang Tan
cc10288e5f Bug fix for assert_template when opening a new session.
See https://github.com/rails/rails/pull/16234#commitcomment-7115670.
2014-07-25 00:38:50 +08:00
Rafael Mendonça França
decb83b9fd Use PROCESS_COUNT to define the number of parallel executors 2014-07-23 14:40:43 -03:00
Aaron Patterson
0b773c30fb specify N=0 to prevent parallel tests (just run tests on the main process) 2014-07-23 10:38:52 -07:00
Guo Xiang Tan
d14f646997 Fix AC::TemplateAssertions instance variables not resetting.
Fixes https://github.com/rails/rails/issues/16119.
2014-07-21 08:47:26 +08:00
Rafael Mendonça França
08754f12e6 Merge branch 'rm-remove-mocha'
Conflicts:
	actionpack/test/abstract_unit.rb
2014-07-19 18:17:13 -03:00
Rafael Mendonça França
fd6aaaa0c3 Stop requiring mocha automatically
We are planning to remove mocha from our test suite because of
performance problems. To make this possible we should stop require mocha
on ActionSupport::TestCase.

This should not affect applications since users still need to add mocha
to Gemfile and this already load mocha.

Added FIXME notes to place that still need mocha removal
2014-07-19 17:35:12 -03:00
Gaurish Sharma
78788ad723 Performed Returns true if redirect/render has happened 2014-07-19 20:06:59 +05:30
Rafael Mendonça França
fe6f436dd9 Merge pull request #16098 from tgxworld/fixes_to_request_test
Fixes to request method test.
2014-07-18 19:20:31 -03:00
Arthur Neves
86433b8d5f
Add CHANGELOG for #14886
Also cleanup test a bit

[related #14886]
[related #14743]
2014-07-18 13:27:43 -04:00
Earl J St Sauver
9ff18e4626
LOCALHOST definition should match any 127.0.0.0/8 address
The entire 127.0.0.0/8 range is assigned to the loopback address, not
only 127.0.0.0/24. This patch allows ActionDispatch::Request::LOCALHOST
to match any IPv4 127.0.0.0/8 loopback address.

The only place that the #local? method was previously under test was
in the show_expectations_test.rb file. I don't particularly like that
that's implicitly where this code is under test, and I feel like I
should move some of that testing code into the
test/dispatch/request_test.rb file, but I wanted some feedback first.

Credit goes to @sriedel for discovering the issue and adding the
patch.
2014-07-18 13:23:45 -04:00
Guo Xiang Tan
ee35b79d4c Prefer to pass block when logging.
The Logger by default includes a guard which checks for the
logging level. By removing the custom logging guards, we can decouple
the logging guard from the logging action to be done.

This also follows the good practice listed on http://guides.rubyonrails.org/debugging_rails_applications.html#impact-of-logs-on-performance.
2014-07-18 15:04:43 +08:00
Guo Xiang Tan
533472dfe9 Remove redundant test.
Since we're stubbing the request, the test is actually just asserting
that `@method = env['REQUEST_METHOD']`. In order to the test against
the methodoverride middleware, we should test it against an actual
request. However, Rack is already covering this scenario so we can
remove this test.
2014-07-18 14:52:17 +08:00
Guo Xiang Tan
095a54502e Fix duplicated test.
There is already another test covering Request#request_method. This
test should cover Request#method.
2014-07-18 14:50:49 +08:00
Guo Xiang Tan
5e11e41420 Update test to clearly reflect what it is testing for. 2014-07-18 14:46:50 +08:00
Guo Xiang Tan
6c5f1692ee Update outdated test.
The current test is asserting against an outdated version of
Request#method where HEAD requests are treated as GET requests.
2014-07-18 14:44:49 +08:00
Aaron Patterson
d4c8068675 reporting is only done in one thread, so we can safely remove the lock
(I think)
2014-07-17 18:43:46 -07:00
Aaron Patterson
5751b7ea58 pass the test reporter by reference
this prevents the array from being dumped as a DRbObject so we can
reduce communication with the server.  the reporter should always exist
on the server side, so we don't have to worry about GC
2014-07-17 14:45:30 -07:00
Aaron Patterson
abd7430895 fix filesystem race condition 2014-07-17 14:04:55 -07:00
Aaron Patterson
8d126c9424 do not restart the service, just stop it 2014-07-17 14:04:55 -07:00
Aaron Patterson
d548a36c8f only parallelize on forking systems 2014-07-17 14:04:55 -07:00
Aaron Patterson
c64bff2c87 [EXPERIMENTAL] run actionpack tests in parallel
only on forking systems though.  Feel free to revert this if it causes
problems.
2014-07-17 12:08:41 -07:00
Aaron Patterson
932386be8a recall should be path_parameters, also make it required
"recall" is a terrible name.  This variable contains the parameters that
we got from the path (e.g. for "/posts/1" it has :controller => "posts",
:id => "1").  Since it contains the parameters we got from the path,
"path_parameters" is a better name.  We always pass path_parameters to
`generate`, so lets make it required.
2014-07-17 11:26:59 -07:00
Aaron Patterson
212057b912 pass the route name to define_url_helper
this allows us to avoid 2 hash allocations per named helper definition,
also we can avoid a `merge` and `delete`.
2014-07-17 11:21:17 -07:00
Aaron Patterson
2888f8653e use a strategy object for generating urls in named helpers
since we know that the route should be a path or fully qualified, we can
pass a strategy object that handles generation.  This allows us to
eliminate an "if only_path" branch when generating urls.
2014-07-17 10:47:58 -07:00
Aaron Patterson
a9765c54ea helper methods are public, so we can just call them
also if you want a path from a named helper, you should call
helper_path, not helper_url(:only_path => true).
2014-07-17 10:04:52 -07:00
Aaron Patterson
0e26271456 extract path building to a method 2014-07-16 18:15:15 -07:00