Commit Graph

10961 Commits

Author SHA1 Message Date
Dave Riddle
578af21a41 prevent --skip-action-cable from erroring when --api option is used 2016-01-22 22:39:01 -08:00
yuuji.yaginuma
82deb76882 remove per_form_csrf_tokens initializer from Rails API
Because the form is not in the Rails API,
`per_form_csrf_tokens` initializer I think unnecessary.
2016-01-22 17:14:43 +09:00
Kasper Timm Hansen
5d9e923d27 Merge pull request #23174 from JuanitoFatas/followup-skip-action-cable
Remove action_cable_meta_tag when skip Action Cable
2016-01-22 08:00:01 +01:00
Jon Moss
a161b8e7f7 Add config/cable.yml to list of default files in Rails generator 2016-01-21 21:30:54 -05:00
JuanitoFatas
cd0d649dc4 Remove action_cable_meta_tag when skip action_cable 2016-01-22 10:21:37 +08:00
Rafael França
77e1b0eb3a Merge pull request #23078 from y-yagi/add_application_mailer_rb_to_mountable_engine
add application_mailer.rb to template of mountable engine
2016-01-21 17:21:33 -05:00
Diego Plentz
98186f5534 updating secrets.yml template to use rails command instead of rake 2016-01-21 11:50:15 -02:00
Matthew Draper
56a9341689 Merge pull request #22950 from maclover7/adapterize-storage-actioncable
Adapterize storage for ActionCable
2016-01-20 16:09:20 +10:30
Jon Moss
980e01eb10 Add em-hiredis and redis as default Gems for new applications 2016-01-18 18:59:31 -05:00
Jon Moss
0016e0410b Adapterize ActionCable storage and extract behavior 2016-01-18 18:58:57 -05:00
Kasper Timm Hansen
be3d4c6ef6 Remove incomplete filter runs all tests in plugins.
Forgot to remove it, when I changed the expectations in 88881d2.
2016-01-18 22:10:26 +01:00
Kasper Timm Hansen
88881d2b50 Don't run all tests when files end in a colon.
If running `bin/rails t test/models/bunny_test.rb:` we'd implicitly run all the
tests in the bunny test. I now highly doubt that people would ever put in a line
filter without a line *and* want that to mean run all tests in that file.

Instead, change regex to require a line digit after the colon, so runs without a
line at the end would fail to require the test file.

This also has the side benefit of breaking requiring a file with many colons:
`bin/rails t test/models/bunny_test.rb:::::::::::::4`

Think this means I've had enough colonoscopy to last me through the year :)
2016-01-18 21:37:12 +01:00
Kasper Timm Hansen
b505d45a5c Merge pull request #23006 from Edouard-chin/code_statistic_ignore_hidde_files
CodeStatistic will now ignore hidden files:
2016-01-18 19:47:17 +01:00
Edouard CHIN
ef233bba9a CodeStatistic will now ignore hidden files:
- Modify the default regex to not match hidden files
2016-01-18 12:56:20 -05:00
Tawan Sierek
221b4aead5 Avoid multiple default paths to server.pid file
Fix bug (#22811) that occurs when rails server is started in daemon mode
and optional path to the `server.pid` file is omitted. Store default path
in a constant instead of evaluating it multiple time using `File.expand_path`.

The bug in detail: The server startup procedure crashes, since it tries to
open a file at `/tmp/pids/server.pid` instead of
`<path to project>/tmp/pids/server.pid`. This bug was introduced in 51211a94bd
when Rack was upgraded from version 1.x to 2.x. Since version 2.x,
Rack does not memoize the options hash [1], and as a consequence
`Rails::Server#default_options` will be evaluated multiple times.
The hash returned by `Rails::Server#default_options` holds the default path
to the `server.pid` file. The path is generated with the method
`File.expand_path`. However, the return value of this method depends on the
current working directory [2], which changes once `Process.daemon` is invoked
by `Rack::Server#daemonize_app` and the process is detached from the current
shell.

Close #22811

[1]https://git.io/vzen2
[2]http://ruby-doc.org/core-2.1.5/File.html#method-c-expand_path
2016-01-16 16:16:43 +01:00
yuuji.yaginuma
6f0bbce50b remove unnecessary ENV[] from log:clear example [ci skip] 2016-01-16 13:27:20 +09:00
yuuji.yaginuma
26b5cbf47b allow symbol to end of string in wrap_in_modules 2016-01-16 08:34:46 +09:00
yuuji.yaginuma
fc3de9118e add application_mailer.rb to template of mountable engine
since 9446e38ba47c9ca3be2ad668d8a8bea0141be6fc, generated mailer inherents from ApplicationMailer,
ApplicationMailer is required in the mountable engine.
2016-01-15 16:18:18 +09:00
Rafael França
b2874aec10 Merge pull request #23014 from jonatack/improve-generated-config-files
Improve generated config initializer files
2016-01-15 03:30:42 -02:00
Jon Atack
9b52e447a6 Improve generated config initializer files
- Fix grammar.
- Improve readability/understanding.
- Wrap lines at 80 characters.

[skip ci]
2016-01-13 12:45:55 +01:00
Yves Senn
64448c29de bring back TEST env for rake test.
Closes #23027.

This does not restore complete backwards compatibility. It simply passes
the contets of the `TEST` env to the new runner.
2016-01-12 19:26:05 +01:00
Kasper Timm Hansen
179df9df68 Merge pull request #23003 from y-yagi/remove_warnings
remove warnings from rake test
2016-01-11 09:07:52 +01:00
Kasper Timm Hansen
72c801476b Merge pull request #22808 from y-yagi/do_not_clear_all_reporters
delete only unnecessary reporter
2016-01-11 09:07:05 +01:00
yuuji.yaginuma
d82bf14003 delete only unnecessary reporter
Reporter that defines its own users at the time of this process are also loaded,
to avoid them from being deleted, to delete only the specified to unnecessary reporter.
2016-01-11 12:36:09 +09:00
yuuji.yaginuma
a2338c5833 remove warnings from rake test
This removes the following warnings.

```
test/application/rake_test.rb:33: warning: ambiguous first argument; put parentheses or a space even after `/' operator
test/application/rake_test.rb:43: warning: ambiguous first argument; put parentheses or a space even after `/' operator
```
2016-01-11 12:33:23 +09:00
Siva Gollapalli
78b5a01252 Added multiple line filters support for test runner 2016-01-10 22:37:01 +05:30
Kasper Timm Hansen
9d681fc74c Merge pull request #22703 from joshsoftware/rake-log-clear
rake log:clear task updated
2016-01-09 18:02:28 +01:00
Kasper Timm Hansen
2ac430f4f9 [ci skip] Clarify some Minitest origins.
It might be tough for readers to know why we implement `===`, and where
the Regexp in `derive_regexp` came from.
2016-01-09 17:24:34 +01:00
Kasper Timm Hansen
69e5547162 Extract line filtering to Railties.
The line filter parsing added to ActiveSupport::TestCase is only half the story
to enable line filtering. The other half, of adding the patterns to the options,
is done in the Minitest plugin that Railties has.

Thus it makes more sense to have the filter in Railties with the other half and
all the line filtering tests.

Move the filter and extend Active Support in an initializer, so that when users
or `rails/all.rb` require `rails/test_unit/railtie` we can still filter by line.
2016-01-09 17:21:21 +01:00
Pramod
68f46a815f rake log:clear task updated refs[#22544]
- Avoided truncating all files if no ENV['LOGS'] specified
- Updated task to accept LOGS=all for truncating all files from log/ i.e. log/*log
- If no LOGS specified will truncates standard environment log files i.e. 'development,test,production'
- CHANGELOG & guide update added
- bin/setup test cases fixed
2016-01-09 13:39:41 +05:30
Sean Griffin
c1a1595740 Merge pull request #22967 from schneems/schneems/generic-metadata
Prevent destructive action on production database
2016-01-08 13:42:48 -07:00
schneems
d70c68d76a Fixing tests and re-locating error checking. 2016-01-08 14:05:20 -06:00
schneems
900bfd94a9 Prevent destructive action on production database
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`.
2016-01-07 18:01:05 -06:00
schneems
81d3bec460 Default new apps to tag logs with request_id
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`.
2016-01-06 15:26:22 -06:00
Richard Schneeman
cc58837f64 Merge pull request #22933 from schneems/schneems/fix-broadcast
[close #22917] Don't output to `STDOUT` twice
2016-01-06 11:03:42 -06:00
schneems
3d10d9d6c3 [close #22917] Don't output to STDOUT twice
When `rails console` or `rails server` are used along with a logger set to output to `STDOUT` then the contents will show up twice. This happens because the logger is extended with `ActiveSupportLogger.broadcast` with a destination of STDOUT even if it is already outputting to `STDOUT`.

Previously PR #22592 attempted to fix this issue, but it ended up causing NoMethodErrors. A better approach than relying on adding a method and flow control is to inspect the log destination directly. For this `ActiveSupport::Logger.logger_outputs_to?` was introduced

```ruby
logger = Logger.new(STDOUT)
ActiveSupport::Logger.logger_outputs_to?(logger, STDOUT)
# => true
```

To accomplish this we must look inside of an instance variable of standard lib's Logger `@logdev`. There is a related Ruby proposal to expose this method in a standard way: https://bugs.ruby-lang.org/issues/11955
2016-01-06 09:55:35 -06:00
Rafael França
0ff3e9466a Merge pull request #22939 from y-yagi/make_generated_controller_test_file_work_correctly
make generated controller test work correctly
2016-01-06 04:51:44 -02:00
yuuji.yaginuma
229064cf3a 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.
2016-01-06 15:12:19 +09:00
Rafael França
ced9612b59 Merge pull request #22275 from mastahyeti/per-form-csrf
Per-form CSRF tokens
2016-01-06 02:55:10 -02:00
Stephen Blackstone
02d2d3cf69 Provide a better error message if a user mistypes the name of script with runner
Add tests for detecting bad options for runner
2016-01-05 23:13:13 -05:00
Akira Matsuda
333aab3d51 ✂️ Unnecessary spacing in the generated code 2016-01-05 12:57:51 +09:00
Ben Toews
3e98819e20 add option for per-form CSRF tokens 2016-01-04 12:26:38 -07:00
yuuji.yaginuma
571b090a85 correctly presence check of application_record.rb in plugin 2016-01-02 14:44:50 +09:00
yuuji.yaginuma
541caffa39 add test of that application_record.rb is generated in plugin 2016-01-02 13:20:46 +09:00
Rafael França
8769224f6d Merge pull request #22874 from prathamesh-sonpatki/create-application-model-under-namespaced-dir-in-plugin
Create application_record.rb under namespaced directory in plugin
2016-01-01 15:27:51 -02:00
Prathamesh Sonpatki
a15c82fb8f Create application_record under namespaced directory in plugin
- Earlier it was creating application_record.rb under `app/models`, after
  this change, it will create application_record.rb under
  `app/models/plugin_name` similar to other application classes.
2016-01-01 20:40:58 +05:30
Shota Iguchi
9e7b594114 Remove a wasted space 2016-01-01 12:54:53 +09:00
Rashmi Yadav
1b608a695c Update copyright notices to 2016 [ci skip] 2015-12-31 18:27:19 +02:00
Rafael França
1f85e1c9f3 Merge pull request #22826 from timrogers/actiondispatch-ssl-config
Configurable redirect and secure cookies for ActionDispatch::SSL
2015-12-31 03:25:47 -02:00
Kasper Timm Hansen
904e3f4465 [ci skip] Space out framework names in USAGE
Two USAGE files were referring to Active Record and Active Model
without a space, which is incorrect because we're referring to
the framework name and not the constants.
2015-12-30 22:54:05 +01:00