aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/test/dispatch
Commit message (Collapse)AuthorAgeFilesLines
* Scrub the invalid paramter value before using it in the errorArthur Neves2017-07-171-1/+2
| | | | | | | You should be able to safely use the String error message. So when finding the paramter has an invalid encoding we need to remove the invalid bytes before using it in the error. Otherwise the caller might get another Encoding error if they use the message.
* [Action Pack] `rubocop -a --only Layout/EmptyLineAfterMagicComment`Koichi ITO2017-07-113-0/+3
|
* Merge pull request #29655 from kirs/frozen-friendly-ap-arMatthew Draper2017-07-103-4/+7
|\ | | | | Prepare AP and AR to be frozen string friendly
| * Prepare AP and AR to be frozen string friendlyKir Shatrov2017-07-063-4/+7
| |
* | Don't call register on custom driverseileencodes2017-07-081-2/+2
|/ | | | | | | | | | | | | It's possible for developers toadd a custom driver and then call it using `driven_by`. Because we were only skipping `register` for `:rack_test` that meant any custom driver would attempt to be registered as well. The three listed here are special because Rails registers them with special options. If you're registering your own custom driver then you don't want to separately register that driver. Fixes #29688
* Merge pull request #29622 from yalab/warning_system_tesing_http_verbEileen M. Uchitelle2017-07-011-0/+32
|\ | | | | Warning http verb method call in SystemTestCase
| * SystemTestCase undef some IntegrationTest methods because it's confused to use.yalab2017-07-011-0/+32
| |
* | Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-0246-46/+0
| | | | | | | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* | Merge pull request #29540 from kirs/rubocop-frozen-stringMatthew Draper2017-07-0246-0/+46
|\ \ | | | | | | | | | Enforce frozen string in Rubocop
| * | Enforce frozen string in RubocopKir Shatrov2017-07-0146-0/+46
| |/
* / Properly register "custom" URL helpers as named helpers.Wilson Bilkovich2017-06-301-0/+6
|/ | | | | | | | | | | | | CustomUrlHelpers were introduced in ce7d5fb2e6, closing issue #22512. They currently register themselves in an ivar that is never accessed. This change removes the @custom_helpers special-case, and registers them the way named routes are normally handled. Without this, you can get route_defined?(:example_url) == false, while still being able to call url_helpers.example_url and example_path. Various popular gems such as 'rspec-rails' make use of route_defined?() when determining how to proxy method calls or whether to define a route.
* Fix missing formats in route-set URLsJonathan del Strother2017-06-231-0/+9
| | | | | | | | | | | Before this change, handle_positional_args would end up mutating @segment_keys if inner_options included path components. Subsequent calls would then be missing the implicit path components. eg: user_path(1, :json) # => "/users/1.json" (correct) user_path(1, format: :json) # => "/users/1.json" (correct, but @segment_keys was mutated) user_path(1, :json) # => "/users/1" (oh no!)
* Merge branch 'master' into bug/filtered_parameters_classLeonel Galán2017-06-166-91/+169
|\
| * SystemTesting::Driver can register capybara-webkit and poltergeistMario Alberto Chávez2017-06-021-2/+16
| | | | | | | | | | | | | | | | | | | | drivers. When using `driver_by` with capybara-webkit or poltergeist, SystemTesting::Driver will register the driver while passing `screen_size` and `options` parameteres. `options` could contain any option supported by the underlying driver.
| * Merge pull request #28132 from mikeycgto/aead-encrypted-cookiesKasper Timm Hansen2017-05-281-86/+120
| |\ | | | | | | AEAD encrypted cookies and sessions
| | * AEAD encrypted cookies and sessionsMichael Coyne2017-05-221-86/+120
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This commit changes encrypted cookies from AES in CBC HMAC mode to Authenticated Encryption using AES-GCM. It also provides a cookie jar to transparently upgrade encrypted cookies to this new scheme. Some other notable changes include: - There is a new application configuration value: +use_authenticated_cookie_encryption+. When enabled, AEAD encrypted cookies will be used. - +cookies.signed+ does not raise a +TypeError+ now if the name of an encrypted cookie is used. Encrypted cookies using the same key as signed cookies would be verified and serialization would then fail due the message still be encrypted.
| * | Merge pull request #28895 from codeforkjeff/fix-session-keys-and-values-methodsMatthew Draper2017-05-281-0/+18
| |\ \ | | | | | | | | Add lazy loading to #keys and #values methods in Session
| | * | Add lazy loading to #keys and #values methods in Sessioncodeforkjeff2017-04-261-0/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes a bug where session.keys and session.values return an empty array unless one of the other methods that does lazy loading from the underlying store is called first. #keys and #values should also call #load_for_read!
| * | | Merge pull request #29176 from bogdanvlviv/define-path-with__dir__Matthew Draper2017-05-262-3/+3
| |\ \ \ | | | | | | | | | | Define path with __dir__
| | * | | Define path with __dir__bogdanvlviv2017-05-232-3/+3
| | | |/ | | |/| | | | | | | | | | | | | | | | | ".. with __dir__ we can restore order in the Universe." - by @fxn Related to 5b8738c2df003a96f0e490c43559747618d10f5f
| * | | Merge pull request #28644 from mtsmfm/set-capybara-app-hostMatthew Draper2017-05-241-0/+12
| |\ \ \ | | |/ / | |/| | Set `Capybara.app_host` through `host!`
| | * | Set `Capybara.app_host` through `host!`Fumiaki MATSUSHIMA2017-04-021-0/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `visit "/"` will visit always "http://127.0.0.1" even when we call `host!`: ```ruby class SomeTest < ApplicationSystemTest def setup host! "http://example.com" end def test_visit visit root_url # => visit "http://example.com/" visit "/" # => visit "http://127.0.0.1/" end end ``` Because Capybara assumes that host is same as the server if we don't set `Capybara.app_host`: https://github.com/teamcapybara/capybara/blob/866c975076f92b5d064ee8998be638dd213f0724/lib/capybara/session.rb#L239
* | | | Merge branch 'master' into bug/filtered_parameters_classLeonel Galán2017-05-173-8/+14
|\| | |
| * | | Fixed string being modified in place causing frozen string errors in Ruby 2.3sepehr5002017-05-151-0/+6
| | | |
| * | | Fix `TestInvalidUrls` with rack 2.0.3yuuji.yaginuma2017-05-161-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Currently, raise `BadRequest` if params encoding is invalid. https://github.com/rails/rails/blob/5-1-stable/actionpack/lib/action_dispatch/http/parameters.rb#L64..L74 https://github.com/rails/rails/blob/5-1-stable/actionpack/lib/action_dispatch/request/utils.rb#L26..L39 However, env values are ensure encoded in ASCII 8 BIT at rack 2.0.3. https://github.com/rack/rack/commit/68db9aa99e3e2775a58621f658b2a7a0f67db459 Therefore, even if specify an invalid urls, it will not cause an error.
| * | | Should escape meta characters in regexpRyuta Kamizono2017-05-071-2/+2
| | |/ | |/|
* | | Merge branch 'master' into bug/filtered_parameters_classLeonel Galán2017-04-252-5/+23
|\| |
| * | Reuse the Parameters#to_h check in the routing helpersRafael Mendonça França2017-04-182-5/+5
| | | | | | | | | | | | | | | Since this protection is now in Parameters we can use it instead of reimplementing again.
| * | Use more specific check for :format in route pathAndrew White2017-04-181-0/+18
| |/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | The current check for whether to add an optional format to the path is very lax and will match things like `:format_id` where there are nested resources, e.g: resources :formats do resources :items end Fix this by using a more restrictive regex pattern that looks for the patterns `(.:format)`, `.:format` or `/` at the end of the path. Note that we need to allow for multiple closing parenthesis since the route may be of this form: get "/books(/:action(.:format))", controller: "books" This probably isn't what's intended since it means that the default index action route doesn't support a format but we have a test for it so we need to allow it. Fixes #28517.
* | Merge branch 'master' into bug/filtered_parameters_classLeonel Galán2017-04-037-1/+536
|\|
| * Make `driven_by` overridableFumiaki MATSUSHIMA2017-03-291-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Sometimes we want to use rack_test partially instead of selenium for test speed: ```ruby class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: {url: "http://chrome:4444/wd/hub"} end class WithJavaScriptTest < ApplicationSystemTestCase end class WithoutJavaScriptTest < ApplicationSystemTestCase driven_by :rack_test end ``` In the abobe case, `WithoutJavaScriptTest` uses selenium because `SystemTestCase` calls superclass' driver on `#initialize` (`self.class.superclass.driver.use`). Using `class_attribute` can handle inherited `driven_by`.
| * Add support for calling nested direct routes (#28462)Andrew White2017-03-171-8/+28
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Not all requirements can be expressed in terms of polymorphic url options so add a `route_for` method that allows calling another direct route (or regular named route) which a set of arguments, e.g: resources :buckets direct :recordable do |recording| route_for(:bucket, recording.bucket) end direct :threadable do |threadable| route_for(:recordable, threadable.parent) end This maintains the context of the original caller, e.g. threadable_path(threadable) # => /buckets/1 threadable_url(threadable) # => http://example.com/buckets/1
| * Merge pull request #28341 from mtsmfm/pass-options-to-driven-byRafael França2017-03-171-1/+2
| |\ | | | | | | Pass options to `driven_by`
| | * Pass options to `driven_by`Fumiaki MATSUSHIMA2017-03-131-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Capybara drivers can handle some options such like `url`. ### before ``` # test/test_helper.rb Capybara.register_driver :remote_chrome do |app| Capybara::Selenium::Driver.new(app, browser: :chrome, url: "http://example.com/wd/hub") end # test/application_system_test_case.rb class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :remote_chrome end ``` ### after ``` # test/application_system_test_case.rb class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, using: :chrome, screen_size: [1400, 1400], options: {url: "http://chrome:4444/wd/hub"} end ```
| * | Remove unnecessary params mungingAndrew White2017-03-151-0/+61
| |/ | | | | | | | | | | | | | | | | | | In 9b654d4 some params munging was added to ensure that they were set whenever `recognize_path` would call either a proc or callable constraint. Since we no longer mutate the environment hash within the method it's now unnecessary and actually causes params to leak between route matches before checking constraints. Fixes #28398.
| * Call system test driver per-instance rather than globallyeileencodes2017-03-093-31/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously the system test subclasses would call `driven_by` when the app booted and not again when the test was initialized which resulted in the driver from whichever class was called last to be used in tests. In rails/rails#28144 the `driven_by` method was changed to run `use` on setup and `reset` on teardown. While this was a viable fix this really pointed to the problem that system test `driven_by` was a global setting, rather than a per-class setting. To alieviate this problem calling the driver should be done on an instance level, rather than on the global level. I added an `initialize` method to `SystemTestCase` which will call `use` on the superclass driver. Running the server has been moved to `start_application` so that it only needs to be called once on boot and no options from `driven_by` were being passed to it. This required a largish rewrite of the tests. Each test needs to utilize the subclass so that it can properly test the drivers. `ActionDispatch::SystemTestCase` shouldn't be called directly anymore.
| * Refactor system test driver/browsereileencodes2017-03-093-16/+11
| | | | | | | | | | | | | | Since using a browser is only for selenium it doesn't really make sense to have a separate class for handling it there. This brings a lot of the if/else out of the main SystemTestCase class and into the Driver class so we can abstract away all that extra work.
| * Do not take screenshot if driver does not support screenshotyuuji.yaginuma2017-03-041-0/+25
| | | | | | | | | | | | | | | | | | | | | | | | | | `Capybara::RackTest::Driver` does not support taking screenshots. If call `#save_screenshot` on `Capybara::RackTest::Driver` will raise the error. ```ruby Error: UsersTest#test_visiting_the_index: Capybara::NotSupportedByDriverError: Capybara::Driver::Base#save_screenshot ``` To prevent errors, if driver does not support screenshot, do not call it.
| * Commit flash changes when using a redirect route.Andrew White2017-02-251-0/+49
| | | | | | | | | | | | | | | | | | | | | | | | | | In ca324a0 the flash middleware was effectively removed by its constructor returning the app it was passed and the `commit_flash` call was moved to the `ActionController::Metal#dispatch` method. This broke any redirect routes that modified the flash because the redirect happens before `dispatch` gets called. To fix it, this commit adds a `commit_flash` call in the `serve` method of `ActionDispatch::Routing::Redirect`. Fixes #27992.
| * Add missing gzip footer check in ActiveSupport::Gzip.decompressDylan Thacker-Smith2017-02-241-1/+1
| | | | | | | | | | | | | | | | A gzip file has a checksum and length for the decompressed data in its footer which isn't checked by just calling Zlib::GzipReader#read. Calling Zlib::GzipReader#close must be called after reading to the end of the file causes this check to be done, which is done by Zlib::GzipReader.wrap after its block is called.
| * Change `SystemTestCase.driven_by` to use `setup`/`teardown` hooksLucas Mazza2017-02-241-12/+14
| | | | | | | | | | | | Previously, `driven_by` would change the Capybara configuration when the test case is loaded, and having multiple test classes with different `driven_by` configs would fail as the last loaded would be effective.
| * Do not take screenshot when test skippedyuuji.yaginuma2017-02-231-0/+10
| |
| * Clarify use of params in `direct`Andrew White2017-02-221-0/+14
| | | | | | | | | | | | | | | | | | Since a `direct` url helper block is evaluated using `instance_exec` then methods that are available in the instance context can be accessed, e.g. the params object in a controller action or view. This wasn't clear from the example so expand on that point and add a test case for this situation.
| * Split direct method into twoAndrew White2017-02-211-35/+75
| | | | | | | | | | Use a separate method called `resolve` for the custom polymorphic mapping to clarify the API.
| * Removed `model_name` method to prevent warningAndrew White2017-02-211-0/+1
| |
| * Support mapping of non-model classesAndrew White2017-02-211-0/+23
| |
| * Raise an error if `direct` is inside a scope blockAndrew White2017-02-211-0/+12
| |
| * Add custom polymorphic mappingAndrew White2017-02-211-1/+71
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Allow the use of `direct` to specify custom mappings for polymorphic_url, e.g: resource :basket direct(class: "Basket") { [:basket] } This will then generate the following: >> link_to "Basket", @basket => <a href="/basket">Basket</a> More importantly it will generate the correct url when used with `form_for`. Fixes #1769.
| * Add test for calling a url helper in Mapper#directAndrew White2017-02-211-0/+7
| |
| * Only accept symbols and strings for Mapper#directAndrew White2017-02-211-0/+17
| |