Commit Graph

124 Commits

Author SHA1 Message Date
yuuji.yaginuma
06b1e5f507 Move test related to tmp:clear task to tmp_test.rb 2017-07-02 09:13:55 +09:00
Matthew Draper
87b3e226d6 Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"
This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing
changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
2017-07-02 02:15:17 +09:30
Matthew Draper
3420a14590 Merge pull request #29540 from kirs/rubocop-frozen-string
Enforce frozen string in Rubocop
2017-07-02 01:11:50 +09:30
Kir Shatrov
cfade1ec7e Enforce frozen string in Rubocop 2017-07-01 02:11:03 +03:00
yuuji.yaginuma
6fbd405a2e Clear screenshots files in tmp:clear task
If system test fails, it creates screenshot under `tmp/screenshots`.
34fe2a4fc7/actionpack/lib/action_dispatch/system_testing/test_helpers/screenshot_helper.rb (L45)

But currently, screenshot files is not cleared by `tmp:clear` task.
This patch make clears screenshot files with `tmp:clear` task as well
as other tmp files.
2017-06-27 07:13:00 +09:00
Rafael Mendonça França
15a4d3c383
Also raise error when VERSION is nil
Fix #28905
2017-04-27 10:21:28 -07:00
bogdanvlviv
bb9d6eb094 Add additional raise UnknownMigrationVersionError
Raise error on the movement of migrations
when the current migration does not exist.
2017-04-19 23:37:58 +03:00
bogdanvlviv
b77d2aa0c3 Fix bin/rails db:forward first migration 2017-04-19 21:32:26 +03:00
Ryuta Kamizono
a315846923 Remove duplicated "test" prefix 2017-04-07 08:40:52 +09:00
Philippe Guay
14739b5e27 Fixes #28359
Add stronger assertions to rake migration tasks to make sure the user is providing a numeric VERSION
An empty string was getting converted to version = 0. This would in turn pass the presence check.

Address linting warning

Add test for rake task and refactor code to meet expectations
In particular passing VERSION=0 should not raise an error.

Addressed Comments for PR #28485. Trimmed empty lines + change of wording for error message

Adjust test for change of wording in error message

Change condition to follow rails idioms
2017-03-26 21:06:02 -04:00
Ryuta Kamizono
416d85b65e
Remove unused require
These files are not using `strip_heredoc`.

Closes #27976
2017-02-12 19:38:49 -07:00
yuuji.yaginuma
bdc8818330 update CREATE TABLE statements generated by sqlite3 command
From SQLite 3.16.0, `IF NOT EXISTS` set to CREATE TABLE statements.
Ref: https://www.sqlite.org/src/info/c7021960f5c070fb

Fixes #27635.
2017-01-19 12:37:09 +09:00
yuuji.yaginuma
447e1a4881 clear all environments log files by default
In #22703, `log:clear` task has been changed to clear only standard environment
log files.
However, it is often to add a non-standard environment(e.g. "staging").
Therefore, I think than it is better to clear all environments log files by default.
2016-10-14 08:52:35 +09:00
yuuji.yaginuma
05fa6f3db6 use rails command in restart task test 2016-09-19 10:17:30 +09:00
Rafael Mendonça França
55f9b8129a
Add three new rubocop rules
Style/SpaceBeforeBlockBraces
Style/SpaceInsideBlockBraces
Style/SpaceInsideHashLiteralBraces

Fix all violations in the repository.
2016-08-16 04:30:11 -03:00
Xavier Noria
b326e82dc0 applies remaining conventions across the project 2016-08-06 20:20:22 +02:00
Xavier Noria
80e66cc4d9 normalizes indentation and whitespace across the project 2016-08-06 20:16:27 +02:00
Xavier Noria
783763bde9 applies new string literal convention in railties/test
The current code base is not uniform. After some discussion,
we have chosen to go with double quotes by default.
2016-08-06 19:16:09 +02:00
Guillermo Iguaran
c62ac07be8 Merge pull request #25652 from prathamesh-sonpatki/rm-boot-rails
Remove unused boot_rails method and it's usage
2016-07-08 14:50:24 -05:00
John Meehan
22a94d9ac4 Fix test to try spec/ directory as opposed to app/spec which I had
accidently set it to.

Made the change and test still passes.
2016-07-05 15:34:13 +01:00
John Meehan
80abee6662 removed extra blank line 2016-07-05 09:01:31 +01:00
John Meehan
a5ce8818d2 Allow rake notes to work with other directories.
Additional directories can be added using
SourceAnnotationExtractor::Annotation.register_directories("spec", "other_dir")

Result: rake notes will now extract notes from these directories.
2016-07-05 01:10:24 +01:00
Prathamesh Sonpatki
d93427840e
Remove unused boot_rails method and it's usage
- The `boot_rails` method from abstract_unit.rb is empty after 2abcdfd978fdcd491576a237e8c6b.
- So let's remove it and its usage.
2016-07-04 09:34:21 +05:30
Mohit Natoo
a83a2b57aa - using rails dev:cache instead of rake dev:cache 2016-04-22 01:01:23 +05:30
Vipul A M
324ae559af Fixed assertions with regex used in dbs tests 2016-04-19 04:02:10 +05:30
bogdanvlviv
26861302c9 Added notice when a database is successfully created or dropped. 2016-04-17 23:12:16 +03: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
Mohit Natoo
4d0c46f6c6 - using rails dev:cache instead of rake dev:cache in test case 2016-03-04 18:36:49 +05:30
Scott Bronson
ba2aea9807 revert dev:cache to rake task, fixes #23410 2016-02-07 14:32:43 -08:00
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
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
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
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
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
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
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
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
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
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
Yoong Kang Lim
6fc83f8efe rake restart should work without a tmp folder
In restart.rake, the creation of tmp/restart.txt
would fail if the tmp folder does not exist in the
app. This is a problem because apps cloned using
git would not have the tmp folder, as the folder is
in .gitignore. This commit creates the tmp folder
if it does not exist.

Fixes #20299

[Yoong Kang Lim, Sunny Juneja]
2015-05-30 00:44:05 -07:00
Rafael Mendonça França
a75f6cfb1b Merge pull request #20326 from hderms/dh/fix_task_bug
Fix rake method definition leaking onto Object
2015-05-27 22:19:57 -03:00
Dermot Haughey
ae5c3c3514 add fixed file
add framework_test

add another test
2015-05-27 19:24:47 -05:00
Yves Senn
557c46a41e Revert "Merge pull request #17920 from calebthompson/dont-rely-on-environment-task-for-schema-load"
This reverts commit 08ff4ccbbb3fb143a02e6752efb974a4bcfcd3bb, reversing
changes made to 6c9ed6dbc62450cdb87559afd15798305e069146.

Caused by #17920.

Closes #19545.

This patch introduced regressions because initializers were no longer
loaded. Specifically missing inflections result in broken restores of
the database.
2015-04-27 11:45:21 +02:00
Jeremy Kemper
5154089c18 Revert "Merge pull request #19404 from dmathieu/remove_rack_env"
Preserving RACK_ENV behavior.

This reverts commit 7bdc7635b885e473f6a577264fd8efad1c02174f, reversing
changes made to 45786be516e13d55a1fca9a4abaddd5781209103.
2015-03-20 08:14:11 -07:00