| Commit message (Collapse) | Author | Age | Files | Lines |
... | |
| | |
|
| |
| |
| |
| |
| |
| |
| | |
This PR introduces a key/value type store to Active Record that can be used for storing internal values. It is an alternative implementation to #21237 cc @sgrif @matthewd.
It is possible to run your tests against your production database by accident right now. While infrequently, but as an anecdotal data point, Heroku receives a non-trivial number of requests for a database restore due to this happening. In these cases the loss can be large.
To prevent against running tests against production we can store the "environment" version that was used when migrating the database in a new internal table. Before executing tests we can see if the database is a listed in `protected_environments` and abort. There is a manual escape valve to force this check from happening with environment variable `DISABLE_DATABASE_ENVIRONMENT_CHECK=1`.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
In high volume applications it can be very difficult to figure out what is happening in logs because each request is not easily identified. For example 3 requests could look something like this:
```
Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:21 +0000
Rendered welcome/index.html.erb within layouts/application (0.1ms)
Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:22 +0000
Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:23 +0000
Rendered welcome/index.html.erb within layouts/application (0.1ms)
Processing by WelcomeController#index as HTML
Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
Processing by WelcomeController#index as HTML
Rendered welcome/index.html.erb within layouts/application (0.1ms)
Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
Processing by WelcomeController#index as HTML
Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
```
The `:request_id` log tag ensures that each request is tagged with a unique identifier. While they are still interleaved it is possible to figure out which lines belong to which requests. Like:
```
[c6034478-4026-4ded-9e3c-088c76d056f1] Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:21 +0000
[c6034478-4026-4ded-9e3c-088c76d056f1] Rendered welcome/index.html.erb within layouts/application (0.1ms)
[abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:22 +0000
[acfab2a7-f1b7-4e15-8bf6-cdaa008d102c] Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:23 +0000
[abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Rendered welcome/index.html.erb within layouts/application (0.1ms)
[c6034478-4026-4ded-9e3c-088c76d056f1] Processing by WelcomeController#index as HTML
[c6034478-4026-4ded-9e3c-088c76d056f1] Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
[abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Processing by WelcomeController#index as HTML
[abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Rendered welcome/index.html.erb within layouts/application (0.1ms)
[abuqw781-5026-6ded-7e2v-788c7md0L6fQ] Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
[acfab2a7-f1b7-4e15-8bf6-cdaa008d102c] Processing by WelcomeController#index as HTML
[acfab2a7-f1b7-4e15-8bf6-cdaa008d102c] Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
```
Now if you have the logs and you find this unique ID you can filter to only look at information from that request. So a filtered log output would be very clear:
```
[c6034478-4026-4ded-9e3c-088c76d056f1] Started GET "/" for 72.48.77.213 at 2016-01-06 20:30:21 +0000
[c6034478-4026-4ded-9e3c-088c76d056f1] Rendered welcome/index.html.erb within layouts/application (0.1ms)
[c6034478-4026-4ded-9e3c-088c76d056f1] Processing by WelcomeController#index as HTML
[c6034478-4026-4ded-9e3c-088c76d056f1] Completed 200 OK in 5ms (Views: 3.8ms | ActiveRecord: 0.0ms)
```
In addition to this benefit the `:request_id` can be set via the `X-Request-ID` header so that the same request could be traced between multiple components. For example a request comes in Nginx (or another load balancer) could assign a request id. As the load balancer processes the request I can log using that id, then when the request is passed on to Rails, the same id is used. That way if a problem is determined to be not caused in Rails it could be traced back to other components with the same ID. You can set a value in nginx for example using something like this:
```
location / {
proxy_pass http://upstream;
proxy_set_header X-Request-Id $pid-$msec-$remote_addr-$request_length;
}
# http://stackoverflow.com/questions/17748735/setting-a-trace-id-in-nginx-load-balancer
```
Heroku sets this header value so problems like timeouts that are logged by like router can be traced back to specific request within the application.
Whether you are using components that are setting request ID or not, all production applications can benefit from the additional debugging information of having a unique identifier for all requests. This change will only affect new applications, anyone can opt out by commenting or removing the line in `config/production.rb`.
|
|\ \
| | |
| | |
| | |
| | | |
y-yagi/make_generated_controller_test_file_work_correctly
make generated controller test work correctly
|
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Since the `#file_name` that not consideration for the namespace, if generate a controller with a namespace,
not the correct url helper generation, it had become an error to run the test.
Modified to generate the correct url helper, even if it is produced a namespace with controller.
|
|\ \ \
| | | |
| | | | |
Per-form CSRF tokens
|
| |/ / |
|
|/ /
| |
| |
| | |
Add tests for detecting bad options for runner
|
| | |
|
| | |
|
|\ \
| | |
| | | |
Configurable redirect and secure cookies for ActionDispatch::SSL
|
| | | |
|
|/ /
| |
| |
| | |
It was removed by mistake at 877a411d0c16baa4e670dae9a28f5cfcc201adc1
|
|\ \
| | |
| | | |
Add colored output to the new test reporter.
|
| | | |
|
|/ /
| |
| |
| |
| | |
`rack-cors` gem is defined in Gemfile by default only if the api,
not defined by default in rails app.
|
|\ \
| | |
| | | |
Ensure Action Cable files are removed when `skip_action_cable` is set.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
The Action Cable generators creates four files which need to be removed
if `skip_action_cable` is set.
1. `app/assets/javascripts/cable.coffee`
2. `app/channels/application_cable/channel.rb`
3. `app/channels/application_cable/connection.rb`
4. `config/redis/cable.yml`
Fixes #22669.
|
| | | |
|
|\ \ \
| | | |
| | | | |
Ensure that assets are enabled back after the test that tests assets are disabled
|
| | | |
| | | |
| | | |
| | | | |
disabled
|
|\ \ \ \
| |/ / /
|/| | |
| | | |
| | | | |
teknofire/fix-using-add_resource-with-a-block-after-gem-call
Fix using add_resource with a block after gem in custom generators
|
| |/ /
| | |
| | |
| | | |
generator template.
|
|\ \ \
| | | |
| | | | |
Action Cable channel generator doesn't create JS assets if options[:rails][:assets] is false
|
| |/ / |
|
|/ /
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
The errors message only was not displayed, as if it did not use the inline reporting,
modified to also information the method name and the like in error are displayed.
```
# before
Failed assertion, no message given.
bin/rails test test/models/user_test.rb:5
```
```
# after
Failure:
UserTest#test_the_truth:
Failed assertion, no message given.
bin/rails test test/models/user_test.rb:5
```
|
| |
| |
| |
| |
| | |
Our logic is complex now and we don't need to check the version to asset
the behavior so I'm removing the checking here.
|
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| |
| | |
We originally chose to apply very strict versioning on the `rails` entry
in the Gemfile, because our future versioning policy was not strongly
defined.
Now it is, and our policy is very much designed on the expectation that
people will regularly update to the latest patch level in their release
series... so we should encourage that.
Of course, Gemfile.lock will do its job and prevent unplanned updates,
just as it does for every other gem in the bundle... but if you run
`bundle update`, we want to get you the latest bug/security fixes
without requiring a manual edit of the Gemfile entry.
Our current version could be a few different shapes, so it takes a bit
of work to find the right specifier, but in principle, we match anything
of the form x.y.*, where x.y matches our current release series.
|
|\ \
| | |
| | |
| | | |
Remove legacy mysql adapter
|
| | | |
|
| | |
| | |
| | |
| | | |
Application* parent
|
|/ / |
|
| |
| |
| |
| | |
I think Markdown is nowadays a better default.
|
| | |
|
| | |
|
| | |
|
| | |
|
|\ \ |
|
| | | |
|
| |\ \
| | |/
| |/| |
Introduce ApplicationRecord, an Active Record layer supertype
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
It's pretty common for folks to monkey patch `ActiveRecord::Base` to
work around an issue or introduce extra functionality. Instead of
shoving even more stuff in `ActiveRecord::Base`, `ApplicationRecord` can
hold all those custom work the apps may need.
Now, we don't wanna encourage all of the application models to inherit
from `ActiveRecord::Base`, but we can encourage all the models that do,
to inherit from `ApplicationRecord`.
Newly generated applications have `app/models/application_record.rb`
present by default. The model generators are smart enough to recognize
that newly generated models have to inherit from `ApplicationRecord`,
but only if it's present.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
Running railties generated app tests in development env can cause unintended
consequences. The environments are different and tests aren't meant to be
run in development mode.
The changes to the generator exposed this issue where the random test
order in the generated apps could cause problems when those tests are
run in development mode.
Particularly we saw failures in `railties/test/application/rake_test.rb`
generated apps that used the scaffold to create applications and then
run the migration and immediately run the tests. The error we saw was
`ActiveRecord::RecordNotFound: Couldn't find User with 'id'=980190962`
and seemed to only occur if the destroy test ran first. I'm not entirely
sure _why_ this causes that error to be thrown but I believe it is
related to the environments being different.
|
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | |
| | | |
In Rails 5.1 `ActionController::TestCase` will be moved out of Rails
into it's own gem. Please use `ActionDispatch::IntegrationTest` going
forward.
This changes the generators to use `ActionDispatch::IntegrationTest` and
the required URL setup (rather than symbols) for each of the controller
actions.
Updated fix to #22076.
|
| |/
| |
| |
| | |
We will wait until 5.1 to make a decision
|
| |
| |
| |
| | |
That would make possible to use it with action cable configuration.
|
|\| |
|
| |
| |
| |
| |
| |
| |
| |
| | |
Apart from specific versioning support, our tests should focus on the
behaviour of whatever version they're accompanying, regardless of when
they were written.
Application code should *not* do this.
|
| | |
|
|/ |
|
|
|
|
|
|
|
|
|
| |
This reverts commit 9712a7a12b7f9e4dcef751ceda8a73c3f4beb11f, reversing
changes made to 3e65c3d3886336e9145438cdeacaf4ebec6a48b8.
Reverting because this caused test failures and while we have a followup
branch there is still one failure that happens randomly and isn't
straight forward to fix.
|