| Commit message (Collapse) | Author | Age | Files | Lines |
|
|
|
|
|
|
| |
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.
|
| |
|
|\
| |
| | |
Prepare AP and AR to be frozen string friendly
|
| | |
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
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
|
|\
| |
| | |
Warning http verb method call in SystemTestCase
|
| | |
|
| |
| |
| |
| |
| | |
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
|
|\ \
| | |
| | |
| | | |
Enforce frozen string in Rubocop
|
| |/ |
|
|/
|
|
|
|
|
|
|
|
|
|
|
| |
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.
|
|
|
|
|
|
|
|
|
|
|
| |
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!)
|
|\ |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |\
| | |
| | | |
AEAD encrypted cookies and sessions
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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.
|
| |\ \
| | | |
| | | | |
Add lazy loading to #keys and #values methods in Session
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
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!
|
| |\ \ \
| | | | |
| | | | | |
Define path with __dir__
|
| | | |/
| | |/|
| | | |
| | | |
| | | |
| | | | |
".. with __dir__ we can restore order in the Universe." - by @fxn
Related to 5b8738c2df003a96f0e490c43559747618d10f5f
|
| |\ \ \
| | |/ /
| |/| | |
Set `Capybara.app_host` through `host!`
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
`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
|
|\| | | |
|
| | | | |
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | |
| | | | |
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.
|
| | |/
| |/| |
|
|\| | |
|
| | |
| | |
| | |
| | |
| | | |
Since this protection is now in Parameters we can use it instead of
reimplementing again.
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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`.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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
|
| |\
| | |
| | | |
Pass options to `driven_by`
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
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
```
|
| |/
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
`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.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| |
| |
| |
| |
| | |
Use a separate method called `resolve` for the custom polymorphic
mapping to clarify the API.
|
| | |
|
| | |
|
| | |
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
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.
|
| | |
|
| | |
|