aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/tasks
Commit message (Collapse)AuthorAgeFilesLines
* Reduce mocking by testing value instead of method callutilum2018-07-093-18/+24
| | | | Step 2 in #33162
* Remove unnecessary Mocha stubsutilum2018-07-074-47/+18
| | | | | | Step 1 in #33162 [utilum + bogdanvlviv]
* assert_called_withutilum2018-04-264-85/+170
|
* assert_calledutilum2018-04-262-23/+24
|
* assert_not_calledutilum2018-04-261-12/+12
|
* Fix two-level database configurations with URLsEugene Kenny2018-03-311-10/+52
| | | | | | | | | An entry in `ActiveRecord::Base.configurations` can either be a connection spec ("two-level") or a hash of specs ("three-level"). We were detecting two-level configurations by looking for the `database` key, but the database can also be specified as part of the `url` key, which meant we incorrectly treated those configurations as three-level.
* Add tests for new rake taskseileencodes2018-03-211-1/+128
|
* Revert "Merge pull request #32075 from eileencodes/delete-default-configuration"eileencodes2018-02-221-0/+16
| | | | | | | | | | This reverts commit 16f279ebd474626577ced858e3626ac4535a33df, reversing changes made to 6c6a30a7c357ce1eafa093d77d2b08684fe50887. The config can be named anything, not just default (although all generated apps will be named default). We can't just delete configs that don't have a database because that will break three-tier configs. Oh well.
* Delete default configurationeileencodes2018-02-211-16/+0
| | | | | | | Because of this default configuration we're constantly checking if the database exists when looping through configurations. This is unnecessary and we should just delete it before we need to loop through configurations.
* Refactor migration to move migrations paths to connectioneileencodes2018-01-181-41/+83
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rails has some support for multiple databases but it can be hard to handle migrations with those. The easiest way to implement multiple databases is to contain migrations into their own folder ("db/migrate" for the primary db and "db/seconddb_migrate" for the second db). Without this you would need to write code that allowed you to switch connections in migrations. I can tell you from experience that is not a fun way to implement multiple databases. This refactoring is a pre-requisite for implementing other features related to parallel testing and improved handling for multiple databases. The refactoring here moves the class methods from the `Migrator` class into it's own new class `MigrationContext`. The goal was to move the `migrations_paths` method off of the `Migrator` class and onto the connection. This allows users to do the following in their `database.yml`: ``` development: adapter: mysql2 username: root password: development_seconddb: adapter: mysql2 username: root password: migrations_paths: "db/second_db_migrate" ``` Migrations for the `seconddb` can now be store in the `db/second_db_migrate` directory. Migrations for the primary database are stored in `db/migrate`". The refactoring here drastically reduces the internal API for migrations since we don't need to pass `migrations_paths` around to every single method. Additionally this change does not require any Rails applications to make changes unless they want to use the new public API. All of the class methods from the `Migrator` class were `nodoc`'d except for the `migrations_paths` and `migrations_path` getter/setters respectively.
* Clear dirty `schema_cache` after `dump_schema_cache`Ryuta Kamizono2017-12-151-0/+1
| | | | | | | `dump_schema_cache` fills `schema_cache` even if the test that modifies the schema has properly cleared the schema cache. Fixes #31463.
* Convert protected_environments to an array of stringsbogdanvlviv2017-12-121-2/+19
| | | | | | | These changes prevent ignoring environments name of which is a `Symbol` ``` config.active_record.protected_environments = ['staging', :production] ```
* Merge pull request #30414 from bogdanvlviv/clear-mysql_database_tasksRafael França2017-11-091-74/+5
|\ | | | | Simplify implementation of `MySQLDatabaseTasks`
| * Simplify implementation of `MySQLDatabaseTasks`bogdanvlviv2017-10-301-72/+3
| | | | | | | | | | | | Don't process MySQL ERROR 1045, raise error instead Make behavior of `MySQLDatabaseTasks` more consistent with behavior of `PostgreSQLDatabaseTasks`
| * Raise error if unsupported charset for mysqlbogdanvlviv2017-10-301-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `blog$ bin/rails db:create` Before: ``` Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5, "username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock", "database"=>"blog_development"}, {:charset=>"utf42"} (If you set the charset manually, make sure you have a matching collation) Created database 'blog_development' Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5, "username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock", "database"=>"blog_test"}, {:charset=>"utf42"} (If you set the charset manually, make sure you have a matching collation) Created database 'blog_test' ``` After: ``` Unsupported charset: '"utf42"' Couldn't create database for {"adapter"=>"mysql2", "encoding"=>"utf42", "pool"=>5, "username"=>"root", "password"=>nil, "socket"=>"/var/run/mysqld/mysqld.sock", "database"=>"blog_development"} rails aborted! Mysql2::Error: Unsupported charset: '"utf42"' ... (stack trace) ... bin/rails:4:in `<main>' Tasks: TOP => db:create (See full trace by running task with --trace) ``` Closes #29683 Related to #27398
* | Fix `bin/rails db:migrate` with specified `VERSION`bogdanvlviv2017-11-061-4/+145
|/ | | | | | Ensure that `bin/rails db:migrate` with specified `VERSION` reverts all migrations only if `VERSION` is `0`. Raise error if target migration doesn't exist.
* Unneeded Mocha stubs for Kernel#systemAkira Matsuda2017-09-251-2/+0
| | | | It's done inside each test via assert_called_with or Kernel.expects
* Fix `can't modify frozen String` error in `DatabaseTasks`yuuji.yaginuma2017-08-302-0/+35
| | | | | | | | | | | | | | | | | Without this, `db:structure:dump` task raises an error as follwing: ``` can't modify frozen String activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:77:in `run_cmd_error' activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:72:in `run_cmd' activerecord/lib/active_record/tasks/sqlite_database_tasks.rb:52:in `structure_dump' activerecord/lib/active_record/tasks/database_tasks.rb:219:in `structure_dump' activerecord/lib/active_record/railties/databases.rake:279:in `block (3 levels) in <main>' railties/lib/rails/commands/rake/rake_command.rb:23:in `block in perform' railties/lib/rails/commands/rake/rake_command.rb:20:in `perform' railties/lib/rails/command.rb:48:in `invoke' railties/lib/rails/commands.rb:18:in `<main>' ```
* Use frozen-string-literal in ActiveRecordKir Shatrov2017-07-194-0/+8
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-024-4/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-014-0/+4
|
* pass `structure_dump_flags` / `structure_load_flags` options before any other:Edouard CHIN2017-06-211-2/+2
| | | | | | | - On Mysql, some command line options that affect option-file handling such as `--no-defaults` have to be passed before any other options - Modified rails to pass them right after the `mysql` command - Ref https://dev.mysql.com/doc/refman/5.7/en/option-file-options.html and https://bugs.mysql.com/bug.php?id=83386 - Ref #27437
* Remove a duplicate test of mysql_rake_testKoichi ITO2017-05-261-7/+0
|
* Respect 'ignore_tables' in SQLite structure dumpGuillermo Iguaran2017-05-151-0/+20
|
* Respect 'ignore_tables' in MySQL structure dumpGuillermo Iguaran2017-05-151-0/+16
|
* Respect `ignore_tables` in Postgres structure dumpRusty Geldmacher2017-05-151-0/+8
| | | | | | When using `sql` as the schema format, or even just doing `rake db:structure:dump`, it would be good to respect the list of ignored tables that has been configured.
* Also raise error when VERSION is nilRafael Mendonça França2017-04-271-1/+2
| | | | Fix #28905
* Refactor DatabaseTasksMigrateTest#test_migrate_receives_correct_env_varsbogdanvlviv2017-04-261-1/+16
| | | | | Add cases to ensure that environment variables VERBOSE and VERSION have correct typecast.
* Fix quoting in db:create grant all statement.Rune Schjellerup Philosof2017-04-201-1/+1
| | | | | | The database name used in the test would have actually shown this if it had tried to execute on a real Mysql instead of being stubbed out (dashes in database names needs quotes).
* Fixes #28359Philippe Guay2017-03-261-0/+8
| | | | | | | | | | | | | | | | 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
* Only remove comments before the first statementAri Pollak2017-02-241-3/+3
|
* Drop comments from structure.sql in postgresqlAri Pollak2017-02-241-3/+16
| | | | Fixes #28153.
* sqlite3_mem tests are broken since 79887593c18919fed49f441d64236362cb755872Akira Matsuda2017-01-101-0/+2
| | | | | since 79887593c18919fed49f441d64236362cb755872, create_all task recreates the connection to AR::Base which doesn't connect to the in_memory database that is set up for tests
* Remove duplicated testutilum2017-01-021-8/+0
| | | | | b8f74860b61782e3b949ade3bb51bff40899e89b provided a nicer version of `#test_structure_load` but the old version was not removed.
* Dump schema cache for custom connectionKir Shatrov2017-01-011-0/+10
| | | | | | | | | Today `rake db:schema:cache:dump` only supports dumping cache for a single connection (`ActiveRecord::Base.connection`). This doesn't work for apps with multiple databases. This PR makes `DatabaseTasks` to provide an API for dumping schema cache for any connection.
* Merge pull request #27437 from kirs/structure-load-dump-flagsKasper Timm Hansen2016-12-293-4/+81
|\ | | | | Make ActiveRecord structure load/dump configurable
| * Make ActiveRecord structure load/dump configurableKir Shatrov2016-12-223-4/+81
| | | | | | | | | | | | | | | | Without this patch it's impossible to pass extra flags to mysqldump/pg_dump when running `rake db:structure:dump` or `load` The following config variables (`structure_load_flags` and `structure_dump_flags`) make it better configurable.
* | assert_equal takes expectation firstAkira Matsuda2016-12-263-9/+9
|/
* Add more rubocop rules about whitespacesRafael Mendonça França2016-10-291-1/+1
|
* improve error message when include assertions failMichael Grosser2016-09-161-1/+1
| | | | | | assert [1, 3].includes?(2) fails with unhelpful "Asserting failed" message assert_includes [1, 3], 2 fails with "Expected [1, 3] to include 2" which makes it easier to debug and more obvious what went wrong
* Add three new rubocop rulesRafael Mendonça França2016-08-161-17/+17
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* normalizes indentation and whitespace across the projectXavier Noria2016-08-063-649/+649
|
* modernizes hash syntax in activerecordXavier Noria2016-08-064-14/+14
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-064-200/+200
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Merge pull request #23301 from ppworks/improve_mysqldumpArthur Nogueira Neves2016-06-171-4/+4
|\ | | | | Improve mysqldump
| * Skip comments when exec mysqldumpNaoto Koshikawa2016-01-281-4/+4
| |
* | PostgreSQL: Fix db:structure:load silent failure on SQL errorRalin Chimev2016-05-101-2/+2
| | | | | | | | | | | | | | | | The command line flag "-v ON_ERROR_STOP=1" should be used when invoking psql to make sure errors are not suppressed. Example: psql -v ON_ERROR_STOP=1 -q -f awesome-file.sql my-app-db Fixes #23818.
* | We are erroring due to nested transaction failures from mysql on ↵Vipul A M2016-05-061-0/+2
| | | | | | | | | | | | | | | | test_migrate_clears_schema_cache_afterward test. Disable transactions for this test. Fixes #24391
* | Fix isolated test failures due to referencing ↵Jeremy Daer2016-04-183-0/+3
| | | | | | | | ActiveRecord::Tasks::DatabaseAlreadyExists before another test happened to make it available
* | Added notice when a database is successfully created or dropped.bogdanvlviv2016-04-174-10/+100
| |