Commit Graph

1150 Commits

Author SHA1 Message Date
bogdanvlviv
26861302c9 Added notice when a database is successfully created or dropped. 2016-04-17 23:12:16 +03:00
yuuji.yaginuma
ab18d37fa4 do not create unnecessary directory
This was added in a4c358f, but `config.assets` has been removed in 5172d93.
Also, do not use env path to `Sprockets::Cache::FileStore` even `sprockets-rails`.
ref: https://github.com/rails/sprockets-rails/blob/master/lib/sprockets/railtie.rb#L129
2016-04-10 20:43:07 +09:00
Prathamesh Sonpatki
9d87ce34f8 Fix rails restart issue with Puma
- We need to pass the restart command to Puma so that it will use it
  while restarting the server.
- Also made sure that all the options passed by user while starting
  the server are used in the generated restart command so that they will
  be used while restarting the server.
- Besides that we need to remove the server.pid file for the previous running
  server because otherwise Rack complains about it's presence.
- We don't care if the server.pid file does not exist. We only want to delete
  it if it exists.
- This also requires some changes on Puma side which are being tracked
  here - https://github.com/puma/puma/pull/936.
- Fixes #23910.
2016-03-30 11:20:15 +05:30
Rafael Mendonça França
8a8325766a Keep all session tests in the same file 2016-03-21 14:04:04 -03:00
Jon Moss
6c6a22176f Fix request.reset_session for API controllers
Due to that `ActionDispatch::Flash` (the flash API's middleware) is not
included for API controllers, the `request.reset_session` method, which
relies on there being a `flash=` method which is in fact defined by the
middleware, was previously breaking. Similarly to how
add46482a540b33184f3011c5c307f4b8e90c9cc created a method to be
overridden by the flash middleware in order to ensure non-breakage, this
is how flashes are now reset.

Fixes #24222
2016-03-19 21:52:45 -04:00
Sean Griffin
b4202fec9f Merge pull request #23939 from akshaymohite/fix-configuration-tests-semantics
Fixed semantics of couple of tests in the configuration_test.rb [ci skip]
2016-03-07 09:47:26 -07:00
Kasper Timm Hansen
af80974f85 Merge pull request #24085 from vipulnsward/i18n-test-addition
i18n fallbacks test fixes
2016-03-06 11:21:04 +01:00
Vipul A M
0c2ccc0f9b - Added i18n test to verify assigning hash directly to fallbacks instead of using map
- Fixed test name for setting fallbacks to config.i18n.fallbacks = [{ :ca => :'es-ES' }]
2016-03-06 13:08:11 +05:30
Ryuta Kamizono
48acc9aefc Fix indentation [ci skip]
Follow up to #24050.
2016-03-05 10:37:30 +09:00
Kasper Timm Hansen
38fa9859fd Merge pull request #24053 from mohitnatoo/rails-dev-cache
using rails dev:cache instead of rake dev:cache in test case
2016-03-04 17:19:22 +01:00
Mohit Natoo
4d0c46f6c6 - using rails dev:cache instead of rake dev:cache in test case 2016-03-04 18:36:49 +05:30
Mohit Natoo
192dd44930 making a test definition more clear. 2016-03-04 18:26:12 +05:30
Mohit Natoo
c91fda40ac [ci skip] using correcting test case names specifying rails routes instead of rake routes 2016-03-04 18:13:33 +05:30
Rafael Mendonça França
e2f08a1c0a Add test to make sure the sprockets cache is not shared per environment 2016-03-02 14:22:02 -03:00
Rafael França
998d21a961 Merge pull request #23935 from y-yagi/convert_cable_coffee_to_javascript
convert cable.coffee to cable.js
2016-03-01 15:19:52 -03:00
Matthew Draper
d3c9d808e3 Publish AS::Executor and AS::Reloader APIs
These should allow external code to run blocks of user code to do
"work", at a similar unit size to a web request, without needing to get
intimate with ActionDipatch.
2016-03-02 02:14:20 +10:30
Teo Ljungberg
5a0dddda09
Address ruby warnings
- Ambiguous first argument
- Mismatched indentation
2016-02-29 09:04:57 +01:00
Akshay
4d6270495d Fixed couple of semantics in the configuration_test.rb 2016-02-28 13:07:26 +05:30
yuuji.yaginuma
861e7d43e3 convert cable.coffee to cable.js
In order to eliminate the dependecy of CoffeeScript.
2016-02-28 15:07:03 +09:00
Ryo Hashimoto
eaec958630 The tasks in the rails task namespace is deprecated in favor of app namespace.
(e.g. `rails:update` and `rails:template` tasks is renamed to `app:update` and `app:template`.)
2016-02-26 19:35:23 +09:00
Jon Moss
8b69f1eeba Enable Action Cable routes by default
This also marks Action Cable routes as internal to Rails.
2016-02-24 19:05:03 -05:00
Prathamesh Sonpatki
5f59c10471 Show permitted flag in the output of AC::Parameters#inspect
- Fixes #23822.
2016-02-24 13:55:37 +05:30
Richard Schneeman
e9b96f0d66 Merge pull request #23734 from schneems/schneems/stdout-again
Alternative to #23638 log to STDOUT via env var
2016-02-23 14:12:03 -06:00
Rafael França
3adc35aefa Merge pull request #23789 from wisetara/wisetara/deprecate-args-ActiveSupport__TestCase#assert_nothing_raised-for-pr
Wisetara/deprecate args active support  test case#assert nothing raised for pr
2016-02-23 13:59:49 -03:00
Aaron Patterson
79887593c1 reestablish previous connection after creating all databases
creating all databases mutates the connection pool.  This patch restores
the connection pool to the connection spec established before creating
all databases.  Fixes #23279
2016-02-23 08:13:09 -08:00
Tara Scherner de la Fuente
926a24a751 remove args from assert_nothing_raised in tests 2016-02-22 22:56:23 -08:00
Aaron Patterson
7a36686c11 make sure rake test respects TESTOPTS
We should be able to pass options to minitest via TESTOPTS environment
variable
2016-02-22 16:14:14 -08:00
Kasper Timm Hansen
b4558c10fb Make collection caching explicit.
Having collection caching that wraps templates and automatically tries
to infer if they are cachable proved to be too much of a hassle.

We'd rather have it be something you explicitly turn on.

This removes much of the code and docs to explain the previous automatic
behavior.

This change also removes scoped cache keys and passing cache_options.
2016-02-20 16:54:32 +01:00
Aaron Patterson
3239ed48d2 move digest cache on to the DetailsKey object
This moves digest calculation cache on to the details key object.
Before, the digest cache was a class level ivar, and one of the keys was
the hash value of the details key object:

  13c4cc3b5a/actionview/lib/action_view/digestor.rb (L28)

An object's hash value is not unique, so it's possible for this cache
key to produce colliding keys with no resolution.  This commit move
cache on to the details key object itself, so we know that the digests
are always unique per details key object.
2016-02-18 08:23:26 -08:00
schneems
4a836dca65 Alternative to #23638 log to STDOUT via env var
People who deploy to containers or other places where they might have some sort of a log wrapping service use stdout. With this change new rails apps can be configured to output to STDOUT via setting `RAILS_LOG_TO_STDOUT` to any value. This allows container images or services to set the value for all apps without having to modify configuration for each application. If an app wants to opt out, they can either delete from the env hash, or remove that configuration. 

cc/ @rafaelfranca
2016-02-17 10:50:29 -06:00
Benjamin Quorning
a623442623 Implement ActionController::Parameters#inspect
Now that AC::Parameters is no longer a Hash, it shouldn't look like a hash.
2016-02-17 14:01:14 +01:00
Yves Senn
b0b61b62f9 Merge pull request #23630 from akshaymohite/correct-test-name-api-only
Correct config option from only_api to api_only in test
2016-02-16 12:00:59 +01:00
Yves Senn
9d37874732 reset ActionMailer::Base.deliveries in ActionDispatch::IntegrationTest.
Whenever you are sending emails in integration tests using the `:test`
delivery method you need to make sure that
`ActionMailer::Base.deliveries` is reset after every test. This piece of
boilerplate code is present in all my applications that send
emails. Let's have `ActionDispatch::IntegrationTest` reset the
deliveries automatically.
2016-02-16 11:20:59 +01:00
Yves Senn
cfd61919da Merge pull request #23631 from y-yagi/generate_mailer_views_in_api
generate mailer views in Rails API
2016-02-15 15:25:52 +01:00
Yves Senn
07e422f58d test runner, relay minitest information about the error location.
This is a follow-up to ea70c29 to bring back the assertion error
location information provided by minitest.
2016-02-15 15:19:24 +01:00
Yves Senn
ea70c295ff Revert "Prefer Minitest's location for test failures."
This reverts commit 0db310586ac3e15be95d2ef27ff40cfa24c05c10.

Closes #23686.

Conflicts:
	railties/test/application/test_runner_test.rb

It's possible that the `result.location` returned by minitest is outside
the test file itself. For example in the case of mocha. This resulted in
bad rerun snipptets:

```
bin/rails test app/models/deliveries/delivery.rb:103
```

Let's always use the first line of the failed test-case in our rerun
snippet. We can display the line number of the assertion error elsewhere.
2016-02-15 15:19:16 +01:00
yuuji.yaginuma
0146a055c0 generate mailer views in Rails API
View files is necessary to send mail, it should be generated even Rails API.
Fixes #23617
2016-02-15 22:13:32 +09:00
Kasper Timm Hansen
8c53b41293 Merge pull request #23611 from abhishekjain16/routes_options
Fix routes to match verb and URL path with -g option also.
2016-02-12 20:20:14 +01:00
Akshay
2d9b774940 Correct config option from only_api to api_only in test 2016-02-12 15:23:37 +05:30
Abhishek Jain
4e3931aac2 Fixes routes to match verbs and path with -g option 2016-02-11 15:16:33 +05:30
David Heinemeier Hansson
437a7a406c Merge pull request #23512 from y-yagi/set_association_name_to_fixture
set association name to generated fixtures if attribute is reference
2016-02-10 17:23:30 +01:00
Scott Bronson
ba2aea9807 revert dev:cache to rake task, fixes #23410 2016-02-07 14:32:43 -08:00
yuuji.yaginuma
00c64e8ae2 set association name to generated fixtures if attribute is reference
It has been changed to require `belongs_to` by default in Rails 5.
Therefore in order to pass the controller test, have association of set to fixtures.

Fixes #23384
2016-02-06 22:41:10 +09:00
Kasper Timm Hansen
84b72a812f Fix mixing line filters with Minitest's -n filter.
Previous commit accidentally broke mixing line filters with string -n filter.

Fix by checking if it is a string and returning it.

We also need to ensure the -n filter carry forward into any other composite filters.

Fix by letting the named filter be extractable, so we'll keep this for the next runnable's
run.
2016-02-05 21:53:27 +01:00
Kasper Timm Hansen
d10b48dd0a Fix model test path typo uncovered in previous commit.
Because of the expanding whitelist for test filters, this test ended up
running the tests on lines 4 and 9 in the post test even though the path
wasn't right.

Happened incidentally because the same line numbers were used in both
account and post test.

Add the .rb line so the file is required correctly and the filters are
applied.
2016-02-03 22:14:51 +01:00
Kasper Timm Hansen
e4f0608164 Fix line filters running tests from multiple runnables.
`derive_regexp` was written with the assumption that we were run from a
blank slate — that if the filter didn't match we might as well return it
because it was nil.

This isn't the case because minitest calls `run` on every runnable. Which
is any subclass of Minitest::Runnable, such as ActiveSupport::TestCase,
ActionDispatch::IntegrationTest as well as any inheriting from those.

Thus after the first `run` we'd have put in a composite filter in
`options[:filter]` making the next `run` create a linked list when it
failed to match the regexp and put the composite filter as the head.

Every runnable would accumulate more and more of the same filters,
which effectively acted like an expanding whitelist and we ran tests
from other runnables.

Clog the accumulation by returning nil if there's no filter to derive
a regexp from.

Note: we pass a seed in the tests because Minitest shuffles the runnables
to ensure the whitelist is expanded enough that the failure is triggered.
2016-02-03 22:13:09 +01:00
yuuji.yaginuma
fae1724398 use rails command in routes task
For other task has become to use the rails command at doc and test,
I think that routes task also it is better to use the rails command.
2016-02-03 08:17:25 +09:00
Kasper Timm Hansen
baae952588 Merge pull request #23225 from vipulnsward/20420-rake-routes-options
Add options for rake routes task
2016-02-01 22:09:22 +01:00
Vipul A M
8a436fdd98 Add options for rake routes task
Add two options: `-c` and `-g`.
`-g` option returns the urls name, verb and path fields that match the pattern.
`-c` option returns the urls for specific controller.

Fixes #18902, and Fixes #20420

[Anton Davydov & Vipul A M]
2016-02-02 00:27:30 +05:30
Yasuo Honda
a374af8b57 Shorten ActiveRecord::InternalMetadata.table_name to ar_internal_metadata
to support Oracle database which only supports 30 byte identifier length
2016-02-01 15:41:37 +00:00
Genadi Samokovarov
38492590cf Introduce new welcome page for new projects
As requested by David in 23233.
2016-01-26 00:27:49 +02:00
Vipul A M
e3b04447f4 Be consistent in testing outputs from railties test and use /bin/rails everywhere(the default behaviour now) instead of mix of /bin/rake /bin/rails everywhere
[Ryo Hashimoto & Vipul A M]
2016-01-24 20:01:02 +05:30
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
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
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
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
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
Ben Toews
3e98819e20 add option for per-form CSRF tokens 2016-01-04 12:26:38 -07:00
Tim Rogers
32b1c90837 Flexible configuration for ActionDispatch::SSL 2015-12-29 13:07:51 +00:00
yuuji.yaginuma
4f8c36ab70 display detailed information in inline reporting
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
```
2015-12-21 07:48:53 +09:00
David Heinemeier Hansson
293d35e256 ApplicationMailer should be generated by default just like every other Application* parent 2015-12-17 17:35:20 -02:00
Rafael Mendonça França
80ba81d2a0 Fix warning 2015-12-17 17:35:20 -02:00
David Heinemeier Hansson
42b9126610 Fix test now that cable is in there by default too 2015-12-16 22:02:43 +01:00
Rafael Mendonça França
4b669dbb91 Merge branch 'master' into merge-action-cable 2015-12-16 17:05:16 -02:00
Rafael Mendonça França
877a411d0c Use sprockets 3 in the Rails 5 release 2015-12-16 16:30:58 -02:00
Rafael França
1d7d8062b2 Merge pull request #22567 from gsamokovarov/introduce-application-record
Introduce ApplicationRecord, an Active Record layer supertype
2015-12-16 14:37:57 -02:00
Genadi Samokovarov
2067fff9e3 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.
2015-12-16 10:30:09 +01:00
eileencodes
becf1bcb1d Run railties generated app tests in test env
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.
2015-12-15 15:19:26 -05:00
Rafael Mendonça França
fc635b5653 Accept a Pathname in Application#config_for
That would make possible to use it with action cable configuration.
2015-12-15 15:53:53 -02:00
Matthew Draper
a6d4e5e532 Internal test migrations use the private 'Current' version
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.
2015-12-15 17:18:09 +10:30
Jorge Bejar
a0343d11f1 Make debug_exception_response_format config depends on api_only when is not set 2015-12-09 10:53:46 -03:00
Jorge Bejar
2430268f18 Add tests for api_only configuration setting 2015-12-09 10:53:46 -03:00
Chuck Callebs
2ddb599710 Add Rails command infrastructure and encapsulate development caching 2015-12-04 13:15:43 -05:00
Rafael Mendonça França
640a300d17 Remove warnings 2015-12-04 00:00:10 -02:00
Matthew Erhard
c3668c3950 Fix failing test using custom file watcher
LoadingTest#test_does_not_reload_constants_on_development_if_custom_file_watcher_always_returns_false in railties/test/application/loading_test.rb is failing with: `NoMethodError: undefined method 'execute' for #<#<Class:0x00000002465a30>:0x00000001f79698>`

The test creates an anonymous class to be used as a custom file watcher using `config.file_watcher=`. Per the Rails guides for Configuring, the class set to `config.file_watcher` “Must conform to ActiveSupport::FileUpdateChecker API”. Per the docs for ActiveSupport::FileUpdateChecker, the API depends on four methods: #initialize, #updated?, #execute, and #execute_if_updated. The custom file watcher in the failing test only implements the first two methods.

This pull request adds #execute and #execute_if_updated to the custom file_watcher, conforming it to the ActiveSupport::FileUpdateChecker API, and passing the test.
2015-12-02 14:00:01 -05:00
Yuki Nishijima
ce83dc98bb Make the static_index config part of the config.public_server config
Also call it `public_server.index_name` so it'll make more sense.
2015-11-16 03:39:24 -08:00
Kasper Timm Hansen
0db310586a Prefer Minitest's location for test failures.
When running tests, the Rails test runner would report the start of the test method as the test failure.

For this test:

```ruby
1 require 'test_helper
2
3 class BunnyTest < ActiveSupport::TestCase
4   test "something failing" do
5     assert false, 'This failed'
6   end
7 end
```

The runner outputs 5 instead of 4:

```
............................................F

This failed

bin/rails test test/models/bunny_test.rb:5

........
```
2015-11-12 21:39:58 +01:00
Kasper Timm Hansen
fa2c96b3f7 Replace serve_static_files in tests with public_file_server.enabled.
Forgot to do it in 748b2f9, when deprecating `serve_static_files`.
2015-11-04 22:40:58 +01:00
Kasper Timm Hansen
748b2f9cb1 Add enabled flag to the public file server.
As discussed in https://github.com/rails/rails/pull/19135#issuecomment-153385986.

Replaces `serve_static_files` to unify the static options under the `public_file_server` wing.

Deprecates `serve_static_files` accessors, but make them use the newer config internally.
2015-11-03 23:10:55 +01:00
yui-knk
a7beeb7faa Make db:migrate:status to render 1_some.rb format migrate files.
`1_valid_people_have_last_names.rb` and
`20150823202140_create_users.rb` are valid migration file name.
But `1_valid_people_have_last_names.rb` is rendered as
`********** NO FILE **********` when `rake db:migrate:status`.

Fix to this bug, this commit includes

* define some API private methdos and a Constant
  `match_to_migration_filename?`, `parse_migration_filename`, and
  `MigrationFilenameRegexp`
* use these methods in `db:migrate:status` task

Example:

These files are in `db/migrate`

* 1_valid_people_have_last_names.rb
* 20150819202140_irreversible_migration.rb
* 20150823202140_add_admin_flag_to_users.rb
* 20150823202141_migration_tests.rb
* 2_we_need_reminders.rb
* 3_innocent_jointable.rb

we can migrate all of them.

Before

```shell
$ bundle exec rake db:migrate:status

...

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     001             ********** NO FILE **********
   up     002             ********** NO FILE **********
   up     003             ********** NO FILE **********
   up     20150819202140  Irreversible migration
   up     20150823202140  Add admin flag to users
   up     20150823202141  Migration tests
```

After

```shell
$ bundle exec rake db:migrate:status

...

 Status   Migration ID    Migration Name
--------------------------------------------------
   up     001             Valid people have last names
   up     002             We need reminders
   up     003             Innocent jointable
   up     20150819202140  Irreversible migration
   up     20150823202140  Add admin flag to users
   up     20150823202141  Migration tests
```
2015-11-02 23:06:57 +09:00
Simon Eskildsen
e58c96766f rails/application: allow passing an env to config_for 2015-10-30 18:57:54 +00:00
Arun Agrawal
4810f401c4 raise ArgumentError when SECRET_KEY_BASE is an integer
If `SECRET_KEY_BASE` or other `secret` gets passed as other then string
we need to raise `ArgumentError` to know that it's a wrong argument.

Closes #22072
2015-10-27 10:18:05 +01:00
Sean Griffin
04bc52f7dc Merge pull request #19924 from iamvery/db-tasks-exit-status
Explicitly exit with status "1" for create and drop failures
2015-10-26 12:27:58 -06:00
Sebastian McKenzie
a97dcde689 Tweaked wording used in some tests. 2015-10-25 08:57:50 +00:00
Jay Hayes
c2e597a736 Exit with non-zero status when db:drop fails
* If the drop task fails for a reason other than the database not
  existing, processing should end. This is indicated by a non-zero
  exit status.
* Since the backtrace is already printed to screen, we forgo
  printing it again by using an explicit call to `exit`.
* ⚠️ This modifies the behavior of the db:create task slightly in
  that the stack trace is no longer printed by default. If the `--trace`
  option is used, it will print the trace _after_ the error message.
2015-10-20 19:17:58 -05:00
Jay Hayes
2893e6c0a4 Exit with non-zero status when db:create fails
* If the create task fails for a reason other than the database already
  existing, processing should end. This is indicated by a non-zero exit
  status.
* Since the backtrace is already printed to screen, we forgo printing it
  again by using an explicit call to `exit`.
* ⚠️ This modifies the behavior of the db:create task slightly in
  that the stack trace is no longer printed by default. If the `--trace`
  option is used, it will print the trace _after_ the error message.
2015-10-20 19:17:58 -05:00
Jay Hayes
1cd35be3eb Fix test of drop failure
* Previously the sqlite3 adapter could not "fail" on drop. Now an error
  is raised when no file exists.
* Also updates purge to be resilient of drop failures. This is how purge
  is expected to behave.
2015-10-20 19:17:58 -05:00
Jay Hayes
213ff7ca0c Add tests to verify exit status for create/drop failures
* Running the db:create task when the database already exists isn't
  really an error case. That is processing may proceed in this case
  because the database exists as requested. So let's validate that
  behavior with a test.
* Likewise, if the database doesn't exist when running the db:drop task
  processing may continue as the requested condition is already met.
  Thus a test.
2015-10-20 19:17:58 -05:00
Jeremy Daer
9d05430c95 Merge pull request #19135 from yuki24/access-control-support
Add basic support for access control headers to ActionDispatch::Static
2015-10-13 11:16:50 -07:00
Arthur Nogueira Neves
9674703671 Merge pull request #17388 from akampjes/master
ActionMailer https on URL with force_ssl = true
2015-10-12 14:26:11 -04:00
Kasper Timm Hansen
11a3e02237 Refactor create_test_file to take a pass option.
Lets us cut the verbose and straight up duplicated setup in 3 tests down to one line.
2015-10-07 22:49:41 +02:00
Kasper Timm Hansen
da832016bf Hide Minitest's aggregated results if outputting inline.
We'd see the failures and errors reported after the run, which is needless, when we've already
reported them.

Turns:

```

.......................................S....................F

This failed

bin/rails test test/models/bunny_test.rb:14

....

Finished in 0.100886s, 1020.9583 runs/s, 1001.1338 assertions/s.

  2) Failure:
BunnyTest#test_something_failing [/Users/kasperhansen/Documents/code/collection_caching_test/test/models/bunny_test.rb:15]:
This failed

103 runs, 101 assertions, 1 failures, 0 errors, 1 skips

You have skipped tests. Run with --verbose for details.
```

Into:

```

...................S.......................................F

This failed

bin/rails test test/models/bunny_test.rb:14

......................

Finished in 0.069910s, 1473.3225 runs/s, 1444.7143 assertions/s.

103 runs, 101 assertions, 1 failures, 0 errors, 1 skips
```
2015-10-07 22:49:41 +02:00
Aaron Patterson
24f9c03d52 Revert "removing Rack::Runtime from the default stack."
This reverts commit 37423e4ff883ad5584bab983aceb4b2b759a1fd8.

Jeremy is right that we shouldn't remove this.  The fact is that many
engines are depending on this middleware to be in the default stack.
This ties our hands and forces us to keep the middleware in the stack so
that engines will work.  To be extremely clear, I think this is another
smell of "the rack stack" that we have in place.  When manipulating
middleware, we should have meaningful names for places in the req / res
lifecycle **not** have engines depend on a particular constant be in a
particular place in the stack.  This is a weakness of the API that we
have to figure out a way to address before removing the constant.

As far as timing attacks are concerned, we can reduce the granularity
such that it isn't useful information for hackers, but is still useful
for developers.
2015-10-03 14:21:31 -07:00
Aaron Patterson
37423e4ff8 removing Rack::Runtime from the default stack.
The runtime header is a potential target for timing attacks since it
returns the amount of time spent on the server (eliminating network
speed).  Total time is also not accurate for streaming responses.

The middleware can be added back via:

```ruby
config.middleware.ues ::Rack::Runtime
```
2015-10-02 14:45:31 -07:00
Jeremy Daer
bb25c671c8 Merge pull request #21794 from jeremy/sprockets/move-asset-manifest-from-toplevel-to-config-subdir
Eliminate overlapping `app/assets` load path
2015-09-29 13:22:56 -07:00
Jeremy Daer
20ec1e922c Eliminate overlapping app/assets load path
* Move `app/assets/manifest.js` to `app/assets/config/manifest.js`.
  Avoid the suggestion that you can/should deep-link `stylesheets/foo`.
* Pull in all toplevel stylesheets and JavaScripts, not just
  `application.js` and `.css`. Demonstrate how to use `link_directory`
  with a specified `.js`/`.css` type.
* Fix RAILS_ENV handling in assets tests.
* Shush warnings spam from third-party libs that distract from tests.
2015-09-29 11:56:58 -07:00
Kasper Timm Hansen
2310fb9d81 Add fail fast to test runner.
Passing `--fail-fast` to the test runner will now abort the test run
on the first failure. The run continues on any unexpected errors.
2015-09-29 08:37:33 +02:00
Kasper Timm Hansen
64a3b09b40 Add inline failure reporting to test runner.
Any failures or errors will be reported inline during the run by default.
Skipped tests will be reported if run in verbose mode.

Any result is output with failure messages and a rerun snippet for that test.

Rerun snippets won't be output after a run, unless `--defer-output` is passed.
2015-09-28 20:30:03 +02:00
eileencodes
0ce3b97fa3 Fix test that was failing because of typo
Here `app` needed to be `get` because we're getting a route. This fixes
the typo so the test passes.
2015-09-27 11:39:32 -04:00
Aditya Kapoor
b5e82d99ef Add missing routing tests for info controller
Vaguely related to #21605 where I proposed to remove index route since it was redirecting to the 'routes' action,

but this was kept so I thought it made sense to add some tests regarding this.
2015-09-27 12:49:20 +05:30
amitkumarsuroliya
563020d8a1 Fix typo in configuration test descritive > descriptive [ci skip] 2015-09-26 18:10:07 +05:30
Aaron Patterson
38d2bf5fd1 mostly remove the ParamsParser middleware
This can still be added to the middleware stack, but is really not
necessary.  I'll follow up with a commit that deprecates the constant
2015-09-18 15:36:55 -07:00
Akira Matsuda
dcecbb4234 File encoding is defaulted to utf-8 in Ruby >= 2.1 2015-09-18 17:05:05 +09:00
Wojciech Wnętrzak
472358d030 Fix displaying mailer previews on non local requests.
When config `action_mailer.show_previews` is set, previews are displayed
regardless of local request check.
2015-09-17 15:57:09 +02:00
yuuji.yaginuma
084a3908fc raise LoadError when a non-existent file or directory is specified to the test runner
Currently, if a file or directory that does not exist was specified in the test runner,
that argument is ignored.
This commit has been modified to cause an error if there is no file or directory.
2015-09-07 08:13:50 +09:00
NehaGautam
c23e06c969 remove unused require ‘set’ 2015-08-25 18:54:53 +05:30
Andrei Istratii
d0e0fbafb2 Migrate to Sprockets 4. 2015-08-19 21:45:46 +03:00
Andrew Kampjes
f0a3af209f ActionMailer https on URL with force_ssl = true
`config.force_ssl = true` will set
config.action_mailer.default_url_options = { protocol: 'https' }

If you have turned on force_ssl, and then gone to the effort of setting
config.action_mailer.default_url_options = {host: 'example.com'} then
you are probably pointing people back to your current app and want
https on that too.
2015-08-14 08:05:11 +12:00
Kasper Timm Hansen
a0fa45c0e6 Merge pull request #21124 from kirs/feature/reload-i18n
Reload I18n.load_path in development
2015-08-10 07:34:13 +02:00
Kir Shatrov
f50e90a1ae Reload I18n locales in development 2015-08-10 00:17:49 +02:00
Chuck Callebs
a01e58afd9 Add rake dev:cache task to enable dev mode caching.
Taken from @Sonopa's commits on PR #19091.

Add support for dev caching via "rails s" flags.

Implement suggestions from @kaspth.

Remove temporary cache file if server does not have flags.

Break at 80 characters in railties/CHANGELOG.md

Remove ability to disable cache based on server options.

Add more comprehensive options: --dev-caching / --no-dev-caching
2015-08-04 23:41:23 -04:00
Yves Senn
bc3956c0d5 Revert "test runner should crash with non existing file argument."
This reverts commit 465f0fbca3d4a1c269038b84ec9cc248fdab5fab.

This breaks some cases where non file / directory arguments are passed
to the runner (for example db:migrate).

I still think that we can get this to work. From what I can tell there
is no reason why db:migrate is passed along to `Minitest.run`. I'll
revert and investigate possible solutions.
2015-08-03 13:42:30 +02:00
Yves Senn
465f0fbca3 test runner should crash with non existing file argument.
Before this patch, using `bin/rails test` with a non existing
file or directory argument would silently swallow the argument and
run the whole test suite.

After the patch the command fails with `cannot load such file --`.
2015-08-03 11:17:07 +02:00
schneems
9b18ba75b1 Fix rake/notes_test
Presumably due to https://github.com/rails/sprockets-rails/pull/265 sprockets was trying to load the "scss" gem but it isn't in the gemfile:

```
ApplicationTests::RakeTests::RakeNotesTest#test_register_a_new_extension:
LoadError: cannot load such file -- sass
```

If we use an empty precompile list, it won't try to load sass.
2015-07-29 20:12:56 -05:00
schneems
4bc2469156 Fix reported regression rails/sprockets-rails#265
We can prevent the UglifierCompressor from being instantiated prematurely by setting precompile to an empty array in this test.
2015-07-29 20:12:56 -05:00
Kasper Timm Hansen
40f79da8f2 Make digest cache work in development.
Avoid computing the same fragment digest many times when looping over templates.

The cache is cleared on every request so template changes are still picked up.
2015-07-18 21:54:19 +02:00
Matthew Draper
383fed5f23 Rely on the load interlock for non-caching reloads, too 2015-07-09 03:31:30 +09:30
Matthew Draper
c37d47e308 Soften the lock requirements when eager_load is disabled
We don't need to fully disable concurrent requests: just ensure that
loads are performed in isolation.
2015-07-09 02:23:23 +09:30
Yves Senn
2183caa24a dump_schema_after_migration applies migration tasks other than db:migrate
Closes #20743.

The task `db:_dump` now only dumps the schema if
`ActiveRecord::Base.dump_schema_after_migration` is true. This has
effects:

- `db:migrate:up`
- `db:migrate:down`
- `db:forward`
- `db:rollback`
2015-06-30 16:36:03 +02:00
Yves Senn
a8f250a22c tests, railties tests should use bin/ executables when possible.
We recommend using the `bin/` executables in our docs and guides.
Let's make sure that our tests execute the same code path.
2015-06-30 11:19:01 +02: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
Sean Griffin
de45e4c6cd Fix failing tests for Rails-API
This looks to be just out of sync tests
2015-06-11 17:24:59 -06:00
Santiago Pastorino
440b334cbb Use new hash syntax 2015-06-11 16:54:13 -03:00
Santiago Pastorino
7d17269be3 Add test to show api only apps allow overriding generator options 2015-06-11 16:54:12 -03:00
Santiago Pastorino
98a9936228 config.api_only = true implies config.generators.api_only = true 2015-06-11 16:54:12 -03:00
Santiago Pastorino
94fdba9c92 Api apps scaffold does not generate assets 2015-06-11 16:54:12 -03:00
Santiago Pastorino
e5b6188b47 Api apps scaffold does not generate helpers 2015-06-11 16:54:12 -03:00
Santiago Pastorino
6d2b405a4e Api apps scaffold does not generate views 2015-06-11 16:54:12 -03:00
Santiago Pastorino
d4fe23c76b API apps scaffold generator generates an apropriate controller 2015-06-11 16:54:11 -03:00
Santiago Pastorino
20939b3fcc config.generators.api_only = true set rails api option on generators 2015-06-11 16:54:11 -03:00
Santiago Pastorino
c19035299a Hide assets, helper, css and js namespaces for api only apps 2015-06-11 16:54:11 -03:00
Santiago Pastorino
212a099ab0 Add AC::API + its middleware stack integration test 2015-06-11 16:54:10 -03:00
Santiago Pastorino
135c059d6f Add config.api_only option to application and remove appropriate middleware when true 2015-06-11 16:54:09 -03:00
Yves Senn
e8d02ccf8c Merge pull request #19571 from kaspth/improve-runner-integration
Improve Test Runner's Minitest integration.
2015-06-08 12:05:12 +02:00
Rafael Mendonça França
847a5ea7db Merge pull request #20444 from y-yagi/can_use_path_helper_method_in_console
modify console of app method in that can use the path helpers
2015-06-06 00:07:45 -03:00
yuuji.yaginuma
4fded7c069 modify console of app method in that can use the path helpers 2015-06-05 18:38:53 +09:00
Arun Agrawal
382f52ddbb Remove warning for setting eager_load
AppTemplate::Application.new does not run load hooks.

To load this configuration we need to use create which will 
run load hooks to load this configuration.
2015-06-05 11:07:16 +02:00
Kasper Timm Hansen
b6fc8e25a1 Improve test runner's Minitest integration.
This also adds free mix and matching of directories, files and lines filters.
Like so:

bin/rails test models/post_test.rb test/integration models/person_test.rb:26

You can also mix in a traditional Minitest filter:

bin/rails test test/integration -n /check_it_out/
2015-06-04 20:57:08 +02:00
Rafael Mendonça França
cecbf9ed32 Merge pull request #18587 from chrismcg/allow_deliver_later_queue_name_to_be_configured
Allow configuration of ActionMailer queue name
2015-06-03 13:25:32 -03:00
Chris McGrath
f5a131aaea Allow configuration of ActionMailer queue name 2015-06-02 10:49:49 +01: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
Yoong Kang Lim
0cb327c549 Add test to ensure tmp:clear works when tmp is missing
See #20299.
2015-05-30 00:44:12 -07:00