Commit Graph

5825 Commits

Author SHA1 Message Date
Prem Sichanugrist
6790228b39 Add deprecation warning for render :text
We've started on discouraging the usage of `render :text` in #12374.
This is a follow-up commit to make sure that we print out the
deprecation warning.
2015-07-17 21:12:47 -04:00
Robin Dupret
ae1b96cfcd Skip a few failing tests on JRuby with the attached tickets 2015-07-17 15:00:00 +02:00
Prem Sichanugrist
14a3bd520d Make AC::Parameters not inherited from Hash
This is another take at #14384 as we decided to wait until `master` is
targeting Rails 5.0. This commit is implementation-complete, as it
guarantees that all the public methods on the hash-inherited Parameters
are still working (based on test case). We can decide to follow-up later
if we want to remove some methods out from Parameters.
2015-07-15 11:11:36 -04:00
Aaron Patterson
468a55b741 Merge pull request #20866 from jdantonio/countdown-latch
Replace `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch` from concurrent-ruby.
2015-07-14 11:06:20 -07:00
Rafael Mendonça França
7645a5f85d Merge pull request #20877 from sikachu/rename-ac-test_response
Change AC::TestResponse to AD::TestResponse
2015-07-14 12:26:30 -03:00
Aaron Patterson
9cff248469 only call methods that are on the superclass
We want to treat the response object as if it's a real response object
(not a test object), so we should only call methods that are on the
superclass.
2015-07-14 07:46:17 -07:00
Prem Sichanugrist
e26d11c876 Change AC::TestResponse to AD::TestResponse
ActionController::TestResponse was removed in d9fe10c and caused a test
failure on Action View as its test case still refers to it.
2015-07-14 09:27:42 -04:00
Aaron Patterson
908bc79729 use a lookup table for assert_response
We shouldn't depend on specific methods imlemented in the TestResponse
subclass because the response could actually be a real response object.

In the future, we should either push the aliased predicate methods in
TestResponse up to the real response object, or remove them
2015-07-13 18:10:36 -07:00
Aaron Patterson
d9fe10cb8a only have one TestResponse class 2015-07-13 17:52:02 -07:00
Jerry D'Antonio
284a9ba8ec Replaced ActiveSupport::Concurrency::Latch with concurrent-ruby.
The concurrent-ruby gem is a toolset containing many concurrency
utilities. Many of these utilities include runtime-specific
optimizations when possible. Rather than clutter the Rails codebase with
concurrency utilities separate from the core task, such tools can be
superseded by similar tools in the more specialized gem. This commit
replaces `ActiveSupport::Concurrency::Latch` with
`Concurrent::CountDownLatch`, which is functionally equivalent.
2015-07-13 15:44:21 -04:00
Aaron Patterson
140d5a3b2f use Rack::Test::UploadedFile when uploading files
We should use rack-test's upload file objects on the test side so that
we will be able to correctly generate mime blob posts in the future
2015-07-09 11:51:45 -07:00
Aaron Patterson
394b7be036 set parameters as a query string
We should convert request parameters to a query string, then let the
request object parse that query string.  This should give us results
that are more similar to the real-world
2015-07-09 10:12:19 -07:00
Aaron Patterson
40ed4eefe4 use JSON to communicate between the controller and the tests 2015-07-09 07:50:41 -07:00
Aaron Patterson
5ea8efecd0 build and assign parameters rather than rely on mutations
We should assign parameters to the request object rather than mutate the
hash that is returned by `query_parameters` or `request_parameters`
2015-07-08 16:43:58 -07:00
Aaron Patterson
f65fd25f04 request objects are no longer recycled
Instead of trying to manually clear out a request object, lets just
allocate a new one.  The rack ENV is reused and cleaned (still), but the
request object is not.
2015-07-08 16:23:32 -07:00
Aaron Patterson
b5a9525932 pass the variant as a parameter to more reflect real world apps 2015-07-08 16:15:50 -07:00
Aaron Patterson
78a5124bf0 add a new constructor for allocating test requests 2015-07-08 16:09:49 -07:00
Aaron Patterson
db41f33d7c make env a required parameter 2015-07-08 15:59:30 -07:00
Aaron Patterson
4b1a0adf54 remove call to build_request 2015-07-08 15:14:41 -07:00
Aaron Patterson
460079a771 let the superclass build the request and response
We should leverage the request / response objects that the superclass
has already allocated for us.
2015-07-08 14:15:53 -07:00
Aaron Patterson
59a9068c3f pass variants in rather than mutating the request.
Variants are typically set in the controller based on some attribute of
the request that the browser sent.  We should make our tests more in
line with reality by doing the same and not mutating the request object.
2015-07-07 15:51:01 -07:00
eileencodes
8363b879fe pass cookies from the jar in the HTTP_COOKIE header
we should be pushing the cookies in via headers rather than maintaining
some object and "recycling" it.
2015-07-07 14:31:34 -07:00
Arthur Nogueira Neves
e598967548 Merge pull request #13897 from gmalette/nested-parameter-filtering-2
Allow filtering params based on parent keys
2015-07-06 16:33:01 +02:00
Kasper Timm Hansen
90ebba6836 Fix the random caching test failure. 2015-07-05 13:53:20 +02:00
eileencodes
4d7b507073 Improve error messages in cookies_test
Using `assert_predicate` and `assert_match` instead of just `assert` is
preferrable because better error messages are output.

In the case of `assert response.cookies.empty?` the error message was
`Failed assertion, no message given.` but now with `assert_predicate` it
will be `Expected {"user_name"=>"david"} to be empty?.`

For `assert_match(/user_name=david/,
response.headers["Set-Cookie"])` as well, the message returned was
unhelpful - `Failed assertion, no message given.` but now will tell what
was expected and what was returned with `Expected /user_name=david/ to
match "user_name=nope; path=/".`
2015-06-27 16:48:20 -04:00
Kasper Timm Hansen
991e98f564 Merge pull request #20276 from davetron5000/revert-head-on-no-template
Allow default_render to take a block to customize behavior when there's no template
2015-06-27 22:18:17 +02:00
Rafael Mendonça França
75b63de5ed Merge pull request #19431 from hmarr/head-routing
Respect routing precedence for HEAD requests
2015-06-22 19:34:37 -03:00
Guillaume Malette
33b93174f0 Allow filtering params based on parent keys
Add the possibility to only filter parameters based on
their full path instead of relying on the immediate key.

    config.filter_parameters += ['credit_card.code']

    { 'credit_card' => { 'code' => '[FILTERED]' },
      'source' => { 'code' => '<%= puts 5 %>' } }
2015-06-22 10:04:11 -04:00
Dave Copeland
6fda6c3778 Override default_render's behavior with a block
In 0de4a23 the behavior when there is a missing template was changed to
not raise an error, but instead head :no_content.  This is a breaking
change and some gems rely on this happening.

To allow gems and other code to work around this, allow
`default_render` to take a block which, if provided, will
execute the contents of that block instead of doing the `head :no_content`.
2015-06-20 12:00:07 -04:00
Arthur Neves
ffba8f79a2
Revert "Merge pull request #20584 from arthurnn/fix_url"
This reverts commit 0b3397872582f2cf1bc6960960a6393f477c55e6, reversing
changes made to 56d52e3749180e6c1dcf7166adbad967470aa78b.

As pointed out on the PR, this will hide development mistakes too, which
is not ideal.
2015-06-17 20:17:44 +02:00
Mehmet Emin İNAÇ
422292dc98 Document, refactor and create test case for ActionDispatch::Response#charset= method 2015-06-17 00:58:50 +03:00
Arthur Neves
e23b314945
Catch InvalidURIError on bad paths on redirect.
Handle URI::InvalidURIError errors on the redirect route method, so it
wont raise a 500 if a bad path is given.
2015-06-16 23:27:49 +02:00
Aaron Patterson
50176b59fa remove header= on the response object.
People should be free to mutate the header object, but not to set a new
header object.  That header object may be specific to the webserver, and
we need to hide it's internals.
2015-06-15 17:54:08 -07:00
Mehmet Emin İNAÇ
cf81a3bae0 Deprecate passing hash as first parameter into ActionController::Head 2015-06-15 23:53:45 +03:00
Kasper Timm Hansen
374b163999 Fix flakyness.
Brought on by my own stupidity :)
2015-06-15 22:04:43 +02:00
Fumiaki MATSUSHIMA
bb0186cf55 ActionDispatch::SSL should keep original header's behavior
`ActionDispatch::SSL` changes headers to `Hash`.
So some headers will be broken if there are some middlewares
on ActionDispatch::SSL and if it uses `Rack::Utils::HeaderHash`.
2015-06-14 23:20:04 +09:00
Yuki Nishijima
5226058163 Add the ability of returning arbitrary headers to ActionDispatch::Static
Now ActionDispatch::Static can accept HTTP headers so that developers
will have control of returning arbitrary headers like
'Access-Control-Allow-Origin' when a response is delivered. They can
be configured through `#config.public_file_server.headers`:

  config.public_file_server.headers = {
    "Cache-Control"               => "public, max-age=60",
    "Access-Control-Allow-Origin" => "http://rubyonrails.org"
  }

Also deprecate `config.static_cache_control` in favor of
`config.public_file_server.headers`.
2015-06-13 09:30:23 -07:00
Jorge Bejar
6c16577311 Return 204 if render is not called in API controllers 2015-06-11 16:54:17 -03:00
Jorge Bejar
8d3e6e5f4d Add test coverage for implicit render in empty actions 2015-06-11 16:54:16 -03:00
Jorge Bejar
a2c9a73084 Include ParamsWrapper in AC::API
ParamsWrapper was initially removed from API controllers according to
the following discusision:
https://github.com/rails-api/rails-api/issues/33

However, we're including it again so Rails API devs can decide
whether to enable or disable it.
2015-06-11 16:54:16 -03:00
Jorge Bejar
08cfe34174 Rename test methods in api conditional get controller tests 2015-06-11 16:54:14 -03:00
Jorge Bejar
674dab30bc Routes resources avoid :new and :edit endpoints if api_only is enabled 2015-06-11 16:54:14 -03:00
Santiago Pastorino
099055de66 Remove extra whitespaces 2015-06-11 16:54:13 -03:00
Santiago Pastorino
440b334cbb Use new hash syntax 2015-06-11 16:54:13 -03:00
Santiago Pastorino
e7b89f1081 Remove Unneeded ApiPublicExceptions middleware, PublicExceptions already does the work 2015-06-11 16:54:13 -03:00
Santiago Pastorino
4c1b437ed7 Use nex hash syntax on tests 2015-06-11 16:54:13 -03:00
Santiago Pastorino
3adb5eac3b Add ApiPublicException middleware 2015-06-11 16:54:10 -03:00
Santiago Pastorino
2d86b6d9ae Move Model test class inside RenderersApiController namespace 2015-06-11 16:54:09 -03:00
Santiago Pastorino
032778eefb Add ActionController API functionality 2015-06-11 16:54:09 -03:00
Yuki Nishijima
a888c3cdc9 Change the index arg of ActionDispatch::Static#new to a kwarg 2015-06-11 04:34:11 -07:00
Aaron Patterson
8037d7eacd extract required_defaults from the conditions hash before constructing the route
this way we can remove the strange "respond_to?" conditional in the
`matches?` loop
2015-06-08 17:18:32 -07:00
Rafael Mendonça França
cf484e3ee3 Merge pull request #19094 from phoet/have_bearer_be_valid_as_well
Have Bearer be valid as well
2015-06-01 12:41:18 -03:00
Rafael Mendonça França
bdfc662a11 Merge pull request #20138 from tgxworld/deprecated_assert_template
Deprecate `assert_template` and `assigns()`.
2015-06-01 12:39:03 -03:00
Rafael Mendonça França
bd83caa666 Merge pull request #20284 from kaspth/fix-caching-test
Move expectation to instance level.
2015-06-01 12:38:08 -03:00
phoet
4b4e890781 allow Bearer as well as Token 2015-06-01 11:41:26 +02:00
phoet
90918b5f22 actually test what the name says 2015-06-01 11:41:26 +02:00
Kasper Timm Hansen
4abe29d813 Replace expectation with state check.
The tests would still pass if the cache call in the rendered templates were removed.
2015-05-30 18:57:10 +02:00
Guo Xiang Tan
ca83436d1b Remove assigns and assert_template. 2015-05-30 14:13:57 +08:00
Arun Agrawal
fbe41a2477 Fix warning about ambiguous first argument 2015-05-29 07:38:45 +02:00
Rafael Mendonça França
73aab036ee Merge pull request #20017 from eliotsykes/configurable-static-index-filename
config.static_index configures directory Index "index.html" filename
2015-05-28 18:53:00 -03:00
Mehmet Emin İNAÇ
44781b6e97 Deprecate :nothing option for render method
`head` method works similar to `render` method with `:nothing` option
2015-05-28 15:13:32 +03:00
Eliot Sykes
3ff39494cd config.static_index configures directory index "index.html" filename
Set `config.static_index` to serve a static directory index file not
named `index`. For example, to serve `main.html` instead of `index.html`
for directory requests, set `config.static_index` to `"main"`.
2015-05-28 09:41:00 +01:00
Rafael Mendonça França
f02f287242 Merge pull request #19808 from byroot/action-parameter
[PoC] Stop shadowing parameters named `action`
2015-05-27 21:43:45 -03:00
Mehmet Emin İNAÇ
01d4e060e2 Add assertion for get? method into test cases 2015-05-27 15:54:56 +03:00
Arthur Nogueira Neves
c36423984d Merge pull request #17788 from sivagollapalli/master
Issue#17703 Test case for tempfile attribute
2015-05-20 22:41:19 +02:00
Rafael Mendonça França
d4cfd54308 Prefer assert_not over refute 2015-05-18 19:33:25 -03:00
Valentine Valyaeff
bad30ed46c ActionDispatch::Journey::Routes#empty? test cases 2015-05-19 01:21:20 +03:00
Prem Sichanugrist
7cb9e20c6c Silence ambiguous first argument warning
This silences:

    actionpack/test/journey/route_test.rb:33: warning: ambiguous first
    argument; put parentheses or a space even after `/' operator
2015-05-04 10:15:50 -04:00
Keenan Brock
ba924a514b Give authentication methods the ability to customize response message.
Digest allowed the messages.
Add the same feature to basic and token
2015-05-03 22:21:19 -04:00
Arthur Nogueira Neves
86929c00c0 Merge pull request #18392 from brainopia/fix_route_requirements
Correct route requirements by overriding defaultls
2015-04-27 09:15:22 -04:00
Rafael Mendonça França
505fa60be2 Merge pull request #19904 from zzak/rm_route_wrapper_internal_hacks
Rm route wrapper internal hacks
2015-04-26 17:27:17 -03:00
Prathamesh Sonpatki
0ad06f2545 Removed unused code from request_forgery_protection tests 2015-04-26 18:52:37 +05:30
Jorge Bejar
8c180cdaf6 Fix rake routes for api apps
Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
2015-04-25 23:14:28 -07:00
Akira Matsuda
9b3fa766d4 Why do we add a top-level constant here? 2015-04-25 17:07:54 +09:00
Bryce Boe
0eaae0291b Remove unused WorkshopsController class in redirect_test. 2015-04-23 16:12:01 -04:00
Jean Boussier
fc9cd89de9 Allow to parameters named action or controller from AC::TestCase helpers 2015-04-18 16:08:33 -04:00
Brian Weaver
c4a83b5454 Fix broken IPv6 addresses handling 2015-04-16 20:57:31 -04:00
Siva Gollapalli
76d8a2a638 Issue#17703 Test case for tempfile attribute
+ To avoid regression I am adding this test case on action pack

Changed to assert from assert_equal

+ Added msg to assertion

Modified msg
2015-04-16 23:11:23 +05:30
Rafael Mendonça França
9ec54d9500 Merge pull request #19736 from kmcphillips/master
Set default form builder for a controller
2015-04-14 11:23:49 -04:00
eileencodes
db8897c2de Use silence_warnings on StaticTests
When 7e504927 was merged setting `Encoding.default_internal` and
`Encoding.default_external` would throw a warning when the ActionPack
tests were run.

Example warning: `actionpack/test/dispatch/static_test.rb:12: warning:
setting Encoding.default_external`

This patch silences the warnings as other similar tests do for setting
default_internal and default_external.
2015-04-14 08:54:13 -04:00
Kevin McPhillips
2b8acdcd21 Override default form builder for a controller 2015-04-13 23:43:34 -04:00
Santiago Pastorino
e085a7ddb8 Revert "Merge pull request #19682 from supercaracal/fix_force_ssl_redirection_flash_error"
This reverts commit d215620340be7cb29e2aa87aab22da5ec9e6e6a7, reversing
changes made to bbbbfe1ac02162ecb5e9a7b560134a3221f129f3.
2015-04-12 22:26:35 -03:00
Taishi Kasuga
3449da4a6c fix a wrong feature test method name 2015-04-11 18:59:56 +09:00
Toshi MARUYAMA
7e50492709 [Rails4 regression] prevent thin and puma cause error in Non ASCII URL on Windows
* https://github.com/rails/rails/issues/19187
* https://github.com/rails/rails/pull/19533
* https://github.com/macournoyer/thin/issues/268

These are serious Rails 4 regression for Redmine Bitnami Windows users.

https://community.bitnami.com/t/problems-with-3-0-1-installation-see-report-inside/30195/

It is not caused on webrick users.

Related:

* https://github.com/rack/rack/issues/732#issuecomment-67677272
* https://github.com/phusion/passenger/issues/1328
2015-04-09 19:25:12 -03:00
Toshi MARUYAMA
2a73b5999e wrap "require 'drb/unix'" by bgin-end at test/abstract_unit.rb
Related: #19617, #19187, #19533, #19689, #19675.

'drb/unix' does not exist on mingw.
2015-04-09 19:25:11 -03:00
Taishi Kasuga
242c5c7ae4 fix fails to force_ssl_redirection if session_store is disabled 2015-04-09 11:21:00 +09:00
Rafael Mendonça França
041c2c879a Merge pull request #19633 from y00rb/sort_router_parameters_duplicated_keys
avoid error when sort mixture keys in symbol and string
2015-04-08 19:01:11 -03:00
Yang Bo
a77de09812 sort_by instead of sort
it is avoid sort errot within different and mixed keys.
used `sort_by` + `block` to list parameter by keys.
keep minimum changes
2015-04-08 22:18:56 +08:00
eileencodes
188934cdac Fix ActionPack tests after changes to missing template logger
After merging #19377 ActionPack tests were missing a require for
`ActiveSupport::LogSubscriber::TestHelper` and change didn't take
into account that logger could be nil. Added the require and only log to
info if logger exists.

This wasn't caught earlier because these tests only run after a merge.
2015-04-06 09:03:13 -04:00
Stephen Bussey
0de4a23d1c head no_content when there is no template or action performed 2015-04-05 15:46:50 -04:00
Sergey Alekseev
7f546318d5 write a test for #form_data?
The initial attempt was to remove the method at all in
4926aa68c9.

The method overrides Rack's `#form_data?`
6f8808d420/lib/rack/request.rb (L172-L184).
Which may have some incorrect implementation actually. `type.nil?` isn't possible I suppose. I'll check.
2015-03-31 10:06:22 +03:00
Xavier Noria
8798788c65 Merge pull request #19544 from shuhei/fix-parameters-const-missing
Return super in ActionController::Parameters.const_missing
2015-03-28 10:01:25 +01:00
Shuhei Kagawa
1b0526eaac Return super in ActionController::Parameters.const_missing
The current implementation of ActionController::Parameters.const_missing
returns `ActionController::Parameters.always_permitted_parameters` even
if its `super` returns a constant without raising error. This prevents its
subclass in a autoloading module/class from taking advantage of
autoloading constants.

    class SomeParameters < ActionController::Parameters
      def do_something
        DefinedSomewhere.do_something
      end
    end

In the code above, `DefinedSomewhere` is to be autoloaded with
`Module.const_missing` but `ActionController::Parameters.const_missing`
returns `always_permitted_parameters` instead of the autoloaded
constant.

This pull request fixes the issue respecting `const_missing`'s `super`.
2015-03-28 10:40:58 +09:00
Rafael Mendonça França
9c3c07b325 Define a setup method instead of using setup as block
setup as block run before setup actlually runs so it will fail for our
case
2015-03-27 16:29:15 -03:00
George Claghorn
9d9cc4777b Provide friendlier access to request variants
Closes #18933.
2015-03-24 12:49:27 -05:00
Andrew White
550c1f0950 Fix failing tests for #19474 2015-03-23 13:15:59 +00:00
Gaurav Sharma
29efc6ee05 remove old unavailable link with relevant fix 2015-03-23 11:18:14 +05:30
adam
b49cac80de Fix handling of empty X_FORWARDED_HOST header.
Previously, an empty X_FORWARDED_HOST header would cause
Actiondispatch::Http:URL.raw_host_with_port to return nil, causing
Actiondispatch::Http:URL.host to raise a NoMethodError.
2015-03-20 20:32:30 +00:00
Harry Marr
34a52c6bce Respect routing precedence for HEAD requests
Fixes the issue described in #18764 - prevents Rack middleware from
swallowing up HEAD requests that should have been matched by a
higher-precedence `get` route, but still allows Rack middleware to
respond to HEAD requests.
2015-03-20 18:13:59 +00:00
Jeremy Kemper
5154089c18 Revert "Merge pull request #19404 from dmathieu/remove_rack_env"
Preserving RACK_ENV behavior.

This reverts commit 7bdc7635b885e473f6a577264fd8efad1c02174f, reversing
changes made to 45786be516e13d55a1fca9a4abaddd5781209103.
2015-03-20 08:14:11 -07:00
eileencodes
adae55f476 Fix kwargs warning in test_get_xml
ActionDispatch::IntegrationTest HTTP request methods will accept only
certain kwargs in the future. This test caused a deprecation warning
when running ActionPack tests. Added `params` and `headers` to fix.
2015-03-20 08:48:10 -04:00
Akshay Vishnoi
c27b2df561 Fix test messages use directly true, false and nil instead of their symbol 2015-03-19 23:47:58 +05:30
Damien Mathieu
d578cbfb5c don't fallback to RACK_ENV when RAILS_ENV is not present 2015-03-19 10:06:28 +01:00
Boris Peterbarg
4be3997c9f Compare content_type with Mime::XML instead of regexp
Regexp is broken for both content types including charsets and for
integration tests, where the content_type is a Mime::Type and not String
2015-03-16 06:35:00 +02:00
Rafael Mendonça França
cf5ec92a8b Merge pull request #19291 from hired/return-truthy-value-from-head
Return truthy value from head method
2015-03-13 11:06:20 -03:00
Joel Hayhurst
d5efb1f9bd Return true from head method
It was returning false in normal circumstances.
This broke the `head :ok and return if` construct.
Add appropriate test.
2015-03-12 14:39:22 -07:00
Guillermo Iguaran
ccf8678cec Merge pull request #19309 from f1sherman/dont-set-session-options-id
Use request.session.id instead of request.session_options[:id]
2015-03-12 11:30:12 -05:00
Brian John
82402e6583 Use request.session.id instead of request.session_options[:id]
As of the upgrade to Rack 1.5, request.session_options[:id] is no
longer populated. Reflect this change in the tests by using
request.session.id instead.

Related change in Rack:
https://github.com/rack/rack/commit/83a270d6
2015-03-12 09:52:38 -05:00
Kohei Suzuki
b60c1fe97b Also skip Content-Encoding and Vary header if 304 2015-03-12 23:32:07 +09:00
Kohei Suzuki
d4103fc232 304 response should not include Content-Type header
Rack::Lint raises an error saying "Content-Type header found in 304
response, not allowed".
2015-03-10 23:39:08 +09:00
eileencodes
2e4a01b92c Call super last in before_setup
This fixes the reasons 4cf3b8a, 303567e, and fa63448 needed to be
reverted in 7142059. The revert has been reverted and this fixes
the issues caused previously.

If we call `super` first we will end up nuking the session settings in the
application tests that do `setup do` - so any session login or cookie
settings will not be persisted thoughout the test sessions.

Calling `super` last prevents `@integration_session` from getting nuked
and set to nil if it's already set.

Test added to prevent regression of this behavior in the future.
2015-03-09 17:11:15 -04:00
eileencodes
d5e55e960c Revert "Revert integration test refactoring that caused app test regressions"
This reverts commit 714205988315d2f98aa3e749747c44470e18676b.
2015-03-09 17:10:24 -04:00
Aaron Patterson
798a14a638 pass a config to the route set
This way we can get the relative_url_root from the application without
setting another global value
2015-03-05 13:12:06 -08:00
Guo Xiang Tan
dad40bf9ea Run ActionPack test cases in random order. 2015-03-06 00:24:22 +08:00
Aaron Patterson
c2108926a4 Drop request class from RouteSet constructor.
If you would like to use a custom request class, please subclass and implemet
the `request_class` method.
2015-03-04 11:02:24 -08:00
Rafael Mendonça França
44ff0313c1 Merge pull request #18775 from yasyf/issue_5122
Fallback to RAILS_RELATIVE_URL_ROOT in `url_for`
2015-03-03 17:19:42 -03:00
Eileen M. Uchitelle
f32b6e243a Merge pull request #19147 from gsamokovarov/work-around-ruby-10695
Work around for upstream Ruby bug #10685
2015-03-02 18:22:31 -05:00
Aaron Patterson
12f2fc56aa Merge pull request #15806 from tgxworld/partition_routes_during_setup
Partition routes during setup.
2015-03-02 15:02:14 -08:00
Zoltan Kiss
f5b192837a Remove unneeded comment. [ci skip] 2015-03-02 11:03:33 -06:00
Robin Dupret
562b0b2368 Skip the failing tests on Rubinius for now 2015-03-02 17:28:12 +01:00
Robin Dupret
586fe4471d Avoid accurate assertions on error messages
Since there are disparities between the raised error messages on the
different implementations, let's avoid being too accurate.
2015-03-02 14:05:07 +01:00
Robin Dupret
022c8be2cf Avoid parallelizing Action Pack's tests on Rubinius
Since the `ForkingExecutor` class seems to be pretty slow on Rubinius
due to DRb (c.f. http://git.io/xIVg), let's avoid running tests with
it on this platform.

Also, the `parallelize_me!` call make the suite to output a bunch of
errors due to rubinius/rubinius#2934 since there are thread-safety
problems with autoloading.
2015-03-02 14:05:07 +01:00
Genadi Samokovarov
707a433870 Work around for upstream Ruby bug #10685
In f6e293ec54f02f83cdb37502bea117f66f87bcae we avoided a segfault in the
tests, however I think we should try to avoid the crash, as it may
happen in user code as well.

Here is what I distiled the bug down to:

```ruby
# Rails case - works on 2.0, 2.1; crashes on 2.2
require 'action_dispatch'

ActionDispatch::Response.new(200, "Content-Type" => "text/xml")

# General case - works on 2.0, 2.1; crashes on 2.2
def foo(optional = {}, default_argument: nil)
end

foo('quux' => 'bar')
```
2015-03-01 16:31:20 +02:00
eileencodes
22e0a22d5f Fix segmentation fault in ActionPack tests
Introduced in f6e293e ActionPack tests began sefaulting. I found that it
was the kwargs and the test causing the seg fault was missing the new
default_headers argument.
2015-02-28 22:34:47 -05:00
Carlos Antonio da Silva
242632167c Merge pull request #19104 from y-yagi/fix_skip_filter
fix NameError in `skip_filter`. callback doesn't exist.
2015-02-27 07:27:42 -03:00
Jeremy Kemper
7142059883 Revert integration test refactoring that caused app test regressions
Haven't diagnosed yet. No similarly failing tests in Rails to work from.

cc @tenderlove, @eileencodes

Revert "there is always an integration session, so remove the check"
Revert "lazily create the integration session"
Revert "use before_setup to set up test instance variables"

This reverts commits 4cf3b8ac47f109fa83a6f66eb97d6cb0eace0d05, 303567e554de26822f3107be55c471d6477a745f, and fa63448420d3385dbd043aca22dba973b45b8bb2.
2015-02-26 18:03:40 -07:00
Jeremy Kemper
a13e52b422 Revert "Merge pull request #18764 from tsun1215/master"
This reverts commit b6dd0c4ddebf5e7aab0a669915cb349ec65e5b88, reversing
changes made to de9a3748c436f849dd1877851115cd94663c2725.
2015-02-26 17:04:08 -07:00
yuuji.yaginuma
0eec7d2c96 fix NameError in skip_filter. callback doesn't exist. 2015-02-27 09:03:31 +09:00
Richard Schneeman
f069b41321 Merge pull request #18434 from brainopia/change_filter_on_rails_info_routes
Change filter on /rails/info/routes to use an actual path regexp from rails
2015-02-26 12:59:43 -06:00
Guo Xiang Tan
89edfbd3a4 Partition routes during setup.
Partitioning of all the routes is currently being done during the
first request. Since there is no need to clear the cache for
`partitioned_routes` when adding a new route. We can move the
partitioning of the routes during setup time.
2015-02-26 12:18:20 +08:00
Jeremy Kemper
f6e293ec54 Fix default headers in test responses
Fixes regression in #18423. Merge default headers for new responses,
but don't merge when creating a response from the last session request.

hat tip @senny ❤️
2015-02-25 09:49:25 -07:00
Rafael Mendonça França
68a2a67116 Merge pull request #18948 from kaspth/automatic-collection-caching
Merge multi_fetch_fragments.
2015-02-25 11:54:07 -03:00
Jeremy Kemper
f4f94081dd Add a failing test demonstrating regression with HEAD requests to Rack apps, re #18764 2015-02-24 15:59:21 -07:00
Yasyf Mohamedali
6c14252d2c Fallback to RAILS_RELATIVE_URL_ROOT in url_for.
Fixed an issue where the `RAILS_RELATIVE_URL_ROOT` environment
variable is not prepended to the path when `url_for` is called.
If `SCRIPT_NAME` (used by Rack) is set, it takes precedence.
2015-02-24 16:04:27 -05:00
Rafael Mendonça França
efc6d49114 Use other controller instead of sharing the controller 2015-02-24 14:59:28 -03:00
Rafael Mendonça França
f6a31f5321 Make TestController available to all test classes 2015-02-24 14:14:15 -03:00
Rafael Mendonça França
6976e1da07 Merge pull request #19060 from iainbeeston/deprecate-skip-action-callback
Deprecate `AbstractController::Callbacks#skip_action_callback`
2015-02-24 13:33:16 -03:00
Iain Beeston
3fbc632843 Deprecate AbstractController::Callbacks#skip_action_callback
As part of #19029, in future `skip_before_action`, `skip_after_action` and
`skip_around_action` will raise an ArgumentError if the specified
callback does not exist. `skip_action_callback` calls all three of these
methods and will almost certainly result in an ArgumentError. If anyone
wants to remove all three callbacks then they can still call the three
individual methods. Therefore let's deprecate `skip_action_callback` now
and remove it when #19029 is merged.
2015-02-24 08:17:24 +00:00
brainopia
321db4aa2e Change filter on /rails/info/routes to use an actual path regexp from rails
Change filter on /rails/info/routes to use an actual path regexp from rails
and not approximate javascript version. Oniguruma supports much more
extensive list of features than javascript regexp engine.

Fixes #18402.
2015-02-23 19:57:01 +03:00
Thiago Pradi
3c181f66a3 Removing old helper that was necessary for compatibility with Ruby 1.8.x 2015-02-22 23:42:51 -03:00
Thiago Pradi
48a0995c7e Removing unused constants from abstract_unit 2015-02-22 23:42:50 -03:00
Thiago Pradi
2b88f65061 Removing unused controller from abstract_unit 2015-02-22 23:42:50 -03:00
Thiago Pradi
71b73b01a6 Removing unused template 2015-02-22 23:42:50 -03:00
Kasper Timm Hansen
11644fd0ce Collections automatically cache and fetch partials.
Collections can take advantage of `multi_read` if they render one template
and their partials begin with a cache call.

The cache call must correspond to either what the collections elements are
rendered as, or match the inferred name of the partial.

So with a notifications/_notification.html.erb template like:

```ruby
<% cache notification %>
  <%# ... %>
<% end %>
```

A collection would be able to use `multi_read` if rendered like:

```ruby
<%= render @notifications %>
<%= render partial: 'notifications/notification', collection: @notifications, as: :notification %>
```
2015-02-21 16:06:57 +01:00
Rafael Mendonça França
027d484f1d Prefer request_id over uuid and test the alias 2015-02-20 20:47:59 -02:00
Rafael Mendonça França
08cec83233 Merge pull request #18218 from brainopia/fix_match_shorthand_in_routes
Don't use shorthand match on routes with inappropriate symbols
2015-02-20 19:28:05 -02:00
Sean Griffin
f3186093d8 Merge pull request #18665 from sgrif/sg-test-route-all
Allow `method: "all"` as a valid routing test option
2015-02-20 09:44:09 -07:00
Rafael Mendonça França
fb876b8a2c Merge pull request #18917 from lautis/non-string-csrf-token
Handle non-string authenticity tokens
2015-02-18 19:37:24 -02:00
Arthur Neves
2ed39424db Implement http_cache_forever to ActionController
Add http_cache_forever to ActionController, so we can cache results
forever.
Things like static pages are a good candidate for this type of caching.

This cache only controls caching headers, so it is up to the browser to
cache those requests.
2015-02-15 11:36:36 -05:00
Ville Lautanala
bf067b41e5 Handle non-string authenticity tokens
Non-string authenticity tokens raised NoMethodError when decoding the
masked token.
2015-02-12 22:24:45 +02:00
Aaron Patterson
303567e554 lazily create the integration session
now we don't have to call reset! everywhere
2015-02-12 12:04:23 -08:00
Rafael Mendonça França
76f6524538 Merge pull request #11790 from printercu/patch-3
ActionController#translate supports symbols
2015-02-12 15:39:17 -02:00
claudiob
050fda0206 Accept a collection in fresh_when and stale?
The methods `fresh_when` and `stale?` from ActionController::ConditionalGet
accept a single record as a short form for a hash. For instance

```ruby
  def show
    @article = Article.find(params[:id])
    fresh_when(@article)
  end
```

is just a short form for:

```ruby
  def show
    @article = Article.find(params[:id])
    fresh_when(etag: @article, last_modified: @article.created_at)
  end
```

This commit extends `fresh_when` and `stale?` to also accept a collection
of records, so that a short form similar to the one above can be used in
an `index` action. After this commit, the following code:

```ruby
def index
  @article = Article.all
  fresh_when(etag: @articles, last_modified: @articles.maximum(:created_at))
end
```

can be simply written as:

```ruby
def index
  @article = Article.all
  fresh_when(@articles)
end
```
2015-02-10 17:08:44 -08:00
claudiob
c7331e057b Fix wrong kwarg "record" from #18872
PR #18772 changed the parameters of `stale?` to use `kwargs`.
[As for this comment](https://github.com/rails/rails/pull/18872/files#r24456288)
the default value for the `etag` parameter should be `record`, not `nil`.

This commit fixes the code and introduces a test that:

- passed before #18872
- fails on the current master (after #18772)
- passes again after setting the default value of `etag` to `record`.
2015-02-10 17:02:24 -08:00
Terence Sun
b9c63b0aae Explicitly ignored wildcard verbs from head_routes
In match_head_routes, deleted the routes in which request.request_method was empty (matches all HTTP verbs) when responding to a HEAD request. This prevents catch-all routes (such as Racks) from intercepting the HEAD request.

Fixes #18698
2015-02-08 12:03:56 -05:00
Rafael Mendonça França
35e2255b7a Merge pull request #18771 from kirs/deprecate-xhr
Migrating xhr methods to keyword arguments syntax
2015-02-05 18:27:47 -02:00
Vipul A M
6eced6a1fe Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 onwards. 2015-02-03 20:51:40 +05:30
Aaron Patterson
e6d8f435a9 Merge pull request #18721 from sj26/pre-discard-flash
Pre-discard flash messages
2015-02-01 08:58:11 -08:00
Andrew White
bf1716bc61 Merge pull request #18769 from gsamokovarov/exception-wrapper-windows-paths
Show proper traces on Windows for the error pages
2015-02-01 16:56:40 +00:00
Kir Shatrov
b19999f3a7 Migrating xhr methods to keyword arguments syntax
in `ActionController::TestCase` and
`ActionDispatch::Integration`

Old syntax:

    `xhr :get, :create, params: { id: 1 }`

New syntax example:

    `get :create, params: { id: 1 }, xhr: true`
2015-02-01 16:07:42 +03:00
Yves Senn
e374db2371 Merge pull request #18759 from yuki24/remove-warning
✂️ warning from controller renderer test
2015-02-01 11:44:12 +01:00
Genadi Samokovarov
872e22c603 Show proper traces on Windows for the error pages
This is an issue brought up by @daniel-rikowski in rails/web-console#91.

Citing his PR proposal here:

> Prior to this, backtrace lines were simply split by a single colon.
>
> Unfortunately that is also the drive letter delimiter in Windows paths
> which resulted in a lot of empty source fragments of "C:0". ("C" from
> the drive letter and 0 from "/path/to/rails/file.rb:16".to_i)
>
> Now the trace line is split by the first colon followed by some digits,
> which works for both Windows and Unix path styles.

Now, the PR was sent against web-console, because of the templates copy
issue we used to had. Instead of bothering the contributor to reopen the
issue against upstream Rails itself, I will make sure he gets the credit
by putting his name in [rails-contributors/hard_coded_authors.rb][].

  [rails-contributors/hard_coded_authors.rb]: (https://github.com/fxn/rails-contributors/blob/master/app/models/names_manager/hard_coded_authors.rb).
2015-02-01 12:00:18 +02:00
robertomiranda
ce8efcf296 Use public Module#include, in favor of https://bugs.ruby-lang.org/issues/8846
ref: https://github.com/rails/rails/pull/18763#issuecomment-72349769
2015-01-31 23:12:41 -05:00
Yuki Nishijima
1bb1b9e8cb ✂️ warning from controller renderer test
rails/actionpack/test/controller/renderer_test.rb:89: warning: possible reference to past scope - defaults
2015-01-31 17:48:55 -08:00
Samuel Cochran
3f528e371c Migrate old flash behaviour 2015-01-30 09:47:03 +11:00
Rafael Mendonça França
50318f5d7e Remove duplicated tests 2015-01-29 19:25:57 -02:00
Rafael Mendonça França
bb6fe7e73a Consistent usage of spaces in hashes across our codebase 2015-01-29 12:19:41 -02:00
Kir Shatrov
baf14ae513 Switch to kwargs in ActionController::TestCase and ActionDispatch::Integration
Non-kwargs requests are deprecated now.
Guides are updated as well.

`post url, nil, nil, { a: 'b' }` doesn't make sense.
`post url, params: { y: x }, session: { a: 'b' }` would be an explicit way to do the same
2015-01-29 14:44:46 +02:00
Samuel Cochran
f7adb34999 Discard from flash before persisting in session 2015-01-29 23:18:55 +11:00
Samuel Cochran
3a102d0528 Fix flash remaining after last flash deleted
Inside a controller functional test after the last flash is deleted it
still persists the flash because to_session_value is nil. We should
delete it from the session when the serialized version is nil, same as
the flash middleware.
2015-01-29 23:00:44 +11:00
Tekin Suleyman
db870f222e Preserve default url options when generating URLs
Fixes an issue that would cause default_url_options to be lost when generating
URLs with fewer positional arguments than parameters in the route definition.
2015-01-28 21:15:52 +00:00
Rafael Mendonça França
39bcbaece6 Just assert the deprecation of one method 2015-01-28 18:50:11 -02:00
Rafael Mendonça França
643f08beeb Merge pull request #18693 from aditya-kapoor/deprecate_via_redirect
Deprecate *_via_redirect integration test methods
2015-01-28 18:34:39 -02:00
Aditya Kapoor
751f752b43 Deprecate *_via_redirect integration test methods 2015-01-28 17:23:30 +05:30
brainopia
572bbab2e6 Improve shorthand matching for routes
Shorthand route match is when controller and action are taken literally from path.
E.g.
get '/foo/bar' # => will use 'foo#bar' as endpoint
get '/foo/bar/baz' # => will use 'foo/bar#baz' as endpoint

Not any path with level two or more of nesting can be used as shortcut.
If path contains any characters outside of /[\w-]/ then it can't be
used as such.

This commit ensures that invalid shortcuts aren't used.

':controller/:action/postfix' - is an example of invalid shortcut
that was previosly matched and led to exception:
"ArgumentError - ':controller/:action' is not a supported controller name"
2015-01-25 03:07:27 +03:00
Zhang Kai Yu
3e02cdc872 Add test for HTTP basic authentication when no credential is given. 2015-01-24 07:17:11 +08:00
Sean Griffin
6cf671b61e Allow method: "all" as a valid routing test option
This allows the test to mirror the production code, since `via: :all` is
a valid option. The behavior in 4.1 did not actually test that it
matched all verbs, but instead defaulted to testing for "GET". This
implementation aims to better handle the intention of passing "all".

What will actually be asserted doesn't quite match up with the generated
route, since it appears to just not create a constraint on the method.
However, I don't think that we can easily test the lack of that
constraint. Testing each of the main 4 HTTP verbs seems to be a
reasonably close approximation, which should be sufficient for our
needs.

Fixes #18511.
2015-01-23 16:03:38 -07:00
Rafael Mendonça França
e36ecf4d77 Merge pull request #18546 from brainopia/action_view_render
A shortcut to setup controller environment
2015-01-22 12:09:32 -02:00
brainopia
656628961c Add ActionController::Base.render 2015-01-22 01:02:13 +03:00
brainopia
801e399e42 Add ActionController::Renderer
Render arbitrary templates outside of controller actions
2015-01-22 01:02:11 +03:00
brainopia
ee6e13f3da Add ActionController::Metal#set_request!
Add `ActionController::Metal#set_request!` to set a request
on controller instance without calling dispatch.
2015-01-21 23:53:38 +03:00
rono23
8a8dac80bb Fix name_for_action in routing 2015-01-19 10:32:27 +09:00
claudiob
7d493a6020 Remove unused AV fixtures from AP tests
When `render` was moved from ActionPack to ActionView in acc8e259,
some fixtures required by the tests were duplicated, but they are
actually only required by ActionView tests.

To give one example, `double_render` is already defined [in the AV tests](72139d8d31/actionview/test/actionpack/controller/render_test.rb (L407))
and is never used in the ActionPack tests.
2015-01-11 13:01:13 -08:00
Kuldeep Aggarwal
90aef23e38 No need of requiring rbconfig, it is by-default loaded 2015-01-10 20:27:18 +05:30
Jonas Baumann
0739480f45 Default headers, removed in controller actions, will not be reapplied to the test response. 2015-01-09 16:55:02 +01:00
Abdelkader Boudih
7644a99d90 Deprecate all *_filter callbacks in favor of *_action callbacks 2015-01-08 20:52:36 +00:00
Rafael Mendonça França
b8e83ce1c5 Merge pull request #18404 from claudiob/rebase-14549
Add test case and documentation for skip_before_filter.
2015-01-08 18:08:02 -02:00
Josef Šimánek
0074bbb07b Add prepend option to protect_from_forgery. 2015-01-08 19:47:19 +01:00
claudiob
9a25603d0a Add test/doc for :if/:except in skip_before_action
The new test/docs further explain the conflicts that can happen when
mixing `:if`/`:unless` options with `:only`/`:except` options in
`skip_before_action`.

The gist is that "positive" filters always have priority over negative
ones.

The previous commit already showed that `:only` has priority over `:if`.

This commit shows that `:if` has priority over `:except`.

For instance, the following snippets are equivalent:

```ruby
skip_before_action :some_callback, if: -> { condition }, except: action
```

```ruby
skip_before_action :some_callback, if: -> { condition }
```
2015-01-08 09:30:31 -08:00
Lauro Caetano
ae9f803c5d Add test case and documentation for skip_before_filter.
Test case for using skip_before_filter with the options :only and :if
both present. In this case, the :if option will be ignored and :only
will be executed.

Closes #14549 (the commit was cherry-picked from there).
2015-01-08 09:13:45 -08:00
brainopia
f9e2496872 Correct route requirements by overriding defaultls (fixes #18373) 2015-01-08 02:53:57 +03:00
brainopia
08d3f0e3b3 Remove ActionController::HideActions (closes #18336) 2015-01-06 23:40:45 +03:00
Carlos Antonio da Silva
afd5e9a7ff Remove respond_to/respond_with placeholder methods
This functionality has been extracted to the responders gem.
2015-01-04 18:22:09 -02:00
Rafael Mendonça França
34e380764e Remove deprecated usage of string keys in URL helpers 2015-01-04 11:58:42 -03:00
Rafael Mendonça França
e4e1fd7ade Remove deprecated only_path option on *_path helpers 2015-01-04 11:58:42 -03:00
Rafael Mendonça França
d282125a18 Remove deprecate *_path helpers in email views 2015-01-04 11:58:42 -03:00
Rafael Mendonça França
1f3b0a8609 Remove deprecated support to define routes with :to option that
doesn't contain `#`
2015-01-04 11:58:41 -03:00
Rafael Mendonça França
4b19d5b7bc Remove deprecated ActionDispatch::Response#to_ary 2015-01-04 11:58:41 -03:00
Rafael Mendonça França
e4cfd353a4 Remove deprecated option use_route in controller tests 2015-01-04 11:58:41 -03:00
Rafael Mendonça França
3456d543eb Merge pull request #10380 from JonRowe/test_all_domain_2_letter_tld
Assert that 2 letter tlds with 3 letter domain names work when option specified.
2015-01-02 21:27:38 -03:00
Rafael Mendonça França
2d743b528c Merge pull request #17978 from kommen/fixed-pr-14903
Ensure append_info_to_payload is called even if an exception is raised.

Conflicts:
	actionpack/CHANGELOG.md
2015-01-02 14:16:15 -03:00
brainopia
95333e1317 Integration requests should work in contexts without setup and teardown 2015-01-02 16:52:32 +03:00
Robin Dupret
7ef7f1cc15 Correctly use the response's status code calling head
Commit 20fece1 introduced the `_status_code` method to fix calls to
`head :ok`. This method has been added on both ActionController::Metal
and ActionDispatch::Response.

As for the latter, this method is just equivalent to the `response_code`
one so commit aefec3c removed it from the `Reponse` object so call to
the `_status_code` method on an ActionController::Base instance would be
handled by the `Metal` class (which `Base` inherits from) but the status
code is not updated according to the response at this level.

The fix is to actually rely on `response_code` for ActionController::Base
instances but this method doesn't exist for bare Metal controllers so we
need to define it.
2014-12-31 16:37:35 +01:00
Prathamesh Sonpatki
75757c5c3b Remove single space response body for head request
- The single space response was added due to a bug in safari
  in cb0f8fda96
  and
  807df4fcf0.
- This was removed from the `render nothing: true` in
  https://github.com/rails/rails/pull/14883.
- Removing it from response of :head also. As :head is more obvious
  alternative to call `render nothing:
  true`(http://guides.rubyonrails.org/layouts_and_rendering.html#using-head-to-build-header-only-responses),
  removing it from head method also.
- Closes #18253.
2014-12-30 20:50:23 +05:30
Godfrey Chan
111f2f4422 Use released rack
`rack.version` was bumped in 28e77c710a
2014-12-19 01:26:19 -08:00
Rafael Mendonça França
e745ae297f Merge pull request #17995 from jethroo/fix/assert_template_with_unsupported_layout_type
assert template should raise ArgumentError for unsupported layout types
2014-12-16 18:35:38 -02:00
Carsten Wirth
7ff31feb14 adding that assert_template with :layout will raise ArgumentError for unknown layout type 2014-12-16 19:30:52 +01:00
Rafael Mendonça França
3bdd110dfe Merge pull request #18052 from timoschilling/reset_variants
allow reseting of request variants
2014-12-16 15:06:01 -02:00
Timo Schilling
e1fb3483d6 allow reseting of request variants
The current implementation of `variants=` don't allow a resetting to nil, wich is the default value.

This results in the following code smell:
```ruby
case request.user_agent
when /iPhone/
  request.variants = :phone
when /iPad/
  request.variants = :ipad
end
```

With the ability to reset variants to nil, it could be:
```ruby
request.variants = case request.user_agent
when /iPhone/
  :phone
when /iPad/
  :ipad
end
```
2014-12-16 11:37:04 +01:00
claudiob
8dfa585db2 Remove misleading test: around_action return false
When an `around_action` does not `yield`, then the corresponding action is
*never* executed and the `after_` actions are *never* invoked.

The value returned by the `around_action` does not have any impact on this:
an `around_action` can "return" `true`, `false`, or `"pizza"`, but as long
as `yield` is not invoked, the corresponding action and after callbacks are
not executed.

The test suite for `ActionController::Callbacks` currently includes separate
tests to distinguish the cases in which a non-yielding `around_actions` returns
`true` or `false`.

In my opinion, having such tests is misleading, giving the impression that the
returned value might have some sort of impact, while it does not. At least
that's the impression I got when I read those tests.

For completeness, the tests were introduced 7 years ago by @NZKoz in e80fabb.
2014-12-15 16:36:50 -08:00
Chris Sinjakli
8f8ccb9901 Don't convert empty arrays to nils when deep munging params 2014-12-15 14:51:07 +00:00
Santiago Pastorino
ef99d4cd3e Merge pull request #18022 from agrobbin/url-helpers-optional-scopes
Allow URL helpers to work with optional scopes
2014-12-13 19:03:30 -02:00
Alex Robbin
a842c5c12d allow URL helpers to work with optional scopes 2014-12-13 15:52:41 -05:00
Nate Berkopec
d57d85a126 ParameterFilter shouldn't try to dup symbol keys 2014-12-13 15:34:59 -05:00
Tatiana Soukiassian
1a50be8231 Fix handling of positional url helper arguments when format is false
There is no need to subtract one from the path_params size when there is
no format parameter because it is not present in the path_params array.

Fixes #17819.
2014-12-13 15:42:15 +00:00
Prem Sichanugrist
61fff0e23b Add AC::Parameters#to_unsafe_h
As suggested in #16299([1]), this method should be a new public API for
retrieving unfiltered parameters from `ActionController::Parameters`
object, given that `Parameters#to_hash` will no longer work in Rails
5.0+ as we stop inheriting `Parameters` from `Hash`.

[1]: https://github.com/rails/rails/pull/16299#issuecomment-50220919
2014-12-12 18:52:10 +07:00
Dieter Komendera
2fde159f6b Ensure append_info_to_payload is called even if an exception is raised.
See:
* https://github.com/rails/rails/pull/14903
* https://github.com/roidrage/lograge/issues/37

Some code by mxrguspxrt from #14903.
2014-12-10 22:13:13 +01:00
T.J. Schuck
ee65f48c26 Mounted Rack apps should have default named routes based on app name
This fixes a regression in 4.2.0 from 4.1.8.

https://github.com/rails/rails/pull/17823 fixed a similar regression regarding _explicitly_ named routes for a mounted Rack app, but there was another regression for the default value.

With a route like:

    Rails.application.routes.draw do
      mount Mountable::Web, at: 'some_route'
    end

The "Prefix" column of rake routes gives the following:

- 4.1.8:         mountable_web
- 4.2.0.beta1-4: [nothing]
- 4.2.0.rc1:     [nothing]
- 4.2.0.rc2:     some_route   <- regression

This fixes the default to go back to being based off the name of the class like the docs specify: 785d04e310/actionpack/lib/action_dispatch/routing/mapper.rb (L558-L560)

Explicitly named routes still work correctly per https://github.com/rails/rails/pull/17823:

    Rails.application.routes.draw do
      mount Mountable::Web, at: 'some_route', as: 'named'
    end

- 4.1.8:         named
- 4.2.0.beta1-4: [nothing]
- 4.2.0.rc1:     [nothing]
- 4.2.0.rc2:     named
2014-12-06 01:17:50 -05:00
Tu Hoang
8ef51f64e5 Typo: Hello = Guten Tag (in German) 2014-12-05 12:54:15 +07:00
Rafael Mendonça França
dfa45ce7e1 Merge pull request #17792 from rockrep/master
allow 'all' for :domain option in addition to :all
2014-12-04 15:21:47 -02:00
claudiob
e428ddecec Remove "rescue" clause around "require 'openssl'"
Some `require 'openssl'` statements were surrounded by `rescue` blocks to deal with Ruby versions that did not support `OpenSSL::Digest::SHA1` or `OpenSSL::PKCS5`.

[As @jeremy explains](a6a0904fcb (commitcomment-8826666)) in the original commit:

> If jruby didn't have jruby-openssl gem, the require wouldn't work. Not sure whether either of these are still relevant today.

According to the [release notes for JRuby 1.7.13](http://www.jruby.org/2014/06/24/jruby-1-7-13.html):

> jruby-openssl 0.9.5 bundled

which means the above `rescue` block is not needed anymore.

All the Ruby versions supported by the current version of Rails provide those OpenSSL libraries, so Travis CI should also be happy by removing the `rescue` blocks.

---

Just to confirm, with JRuby:

    $ ruby --version #=> jruby 1.7.16.1 (1.9.3p392) 2014-10-28 4e93f31 on Java HotSpot(TM) 64-Bit Server VM 1.8.0_20-b26 +jit [darwin-x86_64]
    $ irb
    irb(main):001:0> require 'openssl' #=> true
    irb(main):002:0> OpenSSL::Digest::SHA1 #=> OpenSSL::Digest::SHA1
    irb(main):003:0> OpenSSL::PKCS5 # => OpenSSL::PKCS5

And with Ruby 2.1:

    $ ruby --version #=> ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-darwin13.0]
    $ irb
    irb(main):001:0> require 'openssl' #=> true
    irb(main):002:0> OpenSSL::Digest::SHA1 #=> OpenSSL::Digest::SHA1
    irb(main):003:0> OpenSSL::PKCS5 #=> OpenSSL::PKCS5
2014-12-03 21:58:02 -08:00
Melissa Xie
3b43d1d822 Fix "nonexistent" typo in tests 2014-12-02 19:19:10 -05:00
Rafael Mendonça França
9fd6011f40 Merge pull request #17873 from kirs/refactor-debug-erb
Refactor debug view
2014-12-02 12:55:08 -02:00
Kir Shatrov
083f657c0f Refactor debug view
Avoid logic in ERB and use helpers
2014-12-02 09:45:20 -05:00
Rafael Mendonça França
921576b1d9 Merge pull request #17862 from lucasmazza/lm-hide-action
`_generate_paths_by_default` should always be private.
2014-12-02 11:40:11 -02:00
Aaron Patterson
c9a5ed22d5 Merge pull request #17827 from rkh/rkh-fix-or-pattern
Fix OR in Journey patterns
2014-12-01 07:55:29 -08:00
Sean Griffin
5493d16d9e Merge pull request #17823 from byroot/fix-mount-rack-apps-with-as
Pure rack apps can be mounted with a name
2014-11-29 15:31:12 -07:00
Jean Boussier
f413cbee8d Pure rack apps can be mounted with a name
See 9b15828b5c (commitcomment-8764492)
2014-11-29 09:24:43 -05:00
Erik Michaels-Ober
d1374f99bf Pass symbol as an argument instead of a block 2014-11-29 11:53:24 +01:00
Konstantin Haase
0d690d75fb make OR in journey patterns compile to a valid regular expression 2014-11-29 01:26:10 +01:00
rockrep
f7dbf388bd allow 'all' for :domain option in addition to :all 2014-11-26 13:34:52 -08:00
Matthew Draper
25b14b4d32 Merge pull request #17186 from tgxworld/header_authentication_token
Allow authentication header to not have to specify 'token=' key.
2014-11-27 01:44:13 +10:30
Rafael Mendonça França
f84ffdd5de Merge pull request #17733 from yuki24/do-not-rescue-exception-in-params-parser
Do not rescue Exception in ActionDispatch::ParamsParser
2014-11-25 20:01:58 -02:00
Santiago Pastorino
d3dafaa0b3 Merge branch 'nil_script_name' 2014-11-25 10:31:26 -02:00
Santiago Pastorino
ad973ab8a0 Add regression test case to ensure script_name as nil is not used anymore in url_for 2014-11-25 10:29:48 -02:00
Sean Griffin
9545e6edc7 Merge branch 'deprecate-string-options-in-url-helpers' 2014-11-24 19:18:01 -07:00
Melanie Gilman
4d84922840 Deprecate string options in URL helpers
Fixes https://github.com/rails/rails/issues/16958

[Byron Bischoff & Melanie Gilman]
2014-11-24 21:16:33 -05:00
David Heinemeier Hansson
47728d53aa Merge pull request #17747 from gsamokovarov/missing-template-backtrace
Show source view and backtrace on missing template errors
2014-11-24 23:10:22 +03:00
Genadi Samokovarov
92ace39692 Show source view and backtrace on missing template errors
This will help you debug missing template errors, especially if they
come from a programmatic template selection. Thanks to @dhh for
suggesting that.

As a bonus, also show request and response info on the routing error
page for consistency.
2014-11-24 22:06:11 +02:00
Yuki Nishijima
1d85c707b6 Do not rescue Exception in ParamsParser
Unlike ShowExceptions or PublicExceptions, ParamsParser shouldn't
transform exceptions like Interrupt and NoMemoryError into ParserError.
2014-11-23 13:47:09 -08:00
Godfrey Chan
8e73abbda8 Deprecate use_route in controller tests
Reference #17453
2014-11-23 01:42:46 -08:00
Godfrey Chan
938d130c62 Fix cases where the wrong name is passed to Formatter#generate
These are currently working "by accident" because `match_route` does not check
that the name is valid.
2014-11-23 01:08:53 -08:00
Godfrey Chan
77a276411e Test using ActionController::TestCase with engines
Reference #17453

[Godfrey Chan, Washington Luiz]
2014-11-23 00:07:30 -08:00
Guo Xiang Tan
46041c5208 Anchor should not be appended when set to nil/false.
Fixes https://github.com/rails/rails/issues/17714.
2014-11-23 08:23:26 +08:00
Rafael Mendonça França
1b9e85dbbd Make sure assert_select can assert body tag
This reverts commit f93df52845766216f0fe36a4586f8abad505cac4, reversing
changes made to a455e3f4e9dbfb9630d47878e1239bc424fb7d13.

Conflicts:
	actionpack/lib/action_controller/test_case.rb
	actionview/lib/action_view/test_case.rb
2014-11-18 18:47:22 -02:00
Rafael Mendonça França
5495771938 Merge pull request #17642 from tgxworld/fix_template_assertion_on_assigns
Fix for assigns(:..) resetting template assertions
2014-11-17 11:50:09 -02:00
Calvin Correli
c3e8d15e8b Fix for assigns(:..) resetting template assertions
When calling assigns(:...) or cookies(:...), template assertions would be reset, which they obviously shouldn't be.
2014-11-17 09:49:07 +08:00
Genadi Samokovarov
20ad04e5fc Rename #source_extract to #source_extracts in ExceptionWrapper
It returns multiple source extracts since 1ed264bc. Also cleaned its
result structure, as we no longer need the file in a code extract.
2014-11-16 18:39:45 +02:00
Genadi Samokovarov
e05714fdbc Don't let #{application,framework,full}_trace be nil
Those three can be nil when exception backtrace is nil. This happens and
that forced a couple of nil guards in the code. I'm proposing to make
those always return an array, even on nil backtrace.
2014-11-16 17:17:06 +02:00
Santiago Pastorino
ee74d9c969 Merge pull request #17614 from gsamokovarov/exception-wrapper-basic-tests
Add basic tests for ActionDispatch::ExceptionWrapper
2014-11-14 12:21:22 -02:00