aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/tasks/postgresql_rake_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Use -X when loading structure.sql via psqlJ Smith2018-09-271-3/+3
|
* Removed invalid -X flag for pg_dumpMatthias Winkelmann2018-09-271-7/+7
|
* Ignore psqlrc files when executing psql commandsJ Smith2018-09-171-7/+7
| | | | | | psqlrc files can affect the execution of commands in ways that can hold up execution by blocking or otherwise cause unexpected side effects and should best be ignored when using psql programmatically.
* Prevent leaking of user's DB credentials on `rails db:create` failurebogdanvlviv2018-08-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | Issue #27852 reports that when `rails db:create` fails, it causes leaking of user's DB credentials to $stderr. We print a DB's configuration hash in order to help users more quickly to figure out what could be wrong with his configuration. This commit changes message from "Couldn't create database for #{configuration.inspect}" to "Couldn't create '#{configuration['database']}' database. Please check your configuration.". There are two PRs that fixing it #27878, #27879, but they need a bit more work. I decided help to finish this and added Author of those PRs credit in this commit. Since it is a security issue, I think we should backport it to `5-2-stable`, and `5-1-stable`. Guided by https://edgeguides.rubyonrails.org/maintenance_policy.html#security-issues Fixes #27852 Closes #27879 Related to #27878 [Alexander Marrs & bogdanvlviv]
* Stub with Minitest and test with MethodCallAssertionsutilum2018-08-131-6/+11
|
* Replace permissive Mocha expectationsutilum2018-07-221-23/+66
| | | | | | | | | | | | | | | | | | | | | | | | | Step 6 in #33162 When using Mocha like this: `ActiveRecord::Base.expects(:establish_connection).with(some_args)`, the expectations created look something like this: ``` @expectations= [#<Expectation:0x561350d968e0 expected exactly once, not yet invoked: ActiveRecord::Base.establish_connection("adapter" => "mysql2", "database" => nil) >, #<Expectation:0x561350dab8f8 allowed any number of times, not yet invoked: ActiveRecord::Base.establish_connection(any_parameters) >, #<Expectation:0x561350dc30c0 allowed any number of times, not yet invoked: ActiveRecord::Base.connection(any_parameters) >] ``` Minitest mocking (and the way we use it in `MethodCallAssertions`) expressly refuses to facilitate such permissiive expectations, insisting that all calls be specified in the actual expected order. This patch replaces such calls to `Mocha#expects` with `ActiveSupport::Testing::MethodCallAssertions` and specifies all expected calls in the epxected order.
* Use MethodCallAssertions instead of Mocha#expectsutilum2018-07-191-35/+61
| | | | | | | | | | Many calls to `Mocha#expects` preceded the introduction of `ActiveSupport::Testing::MethodCallAssertions` in 53f64c0fb, and many are simple to replace with `MethodCallAssertions`. This patch makes all these simple replacements. Step 5 in #33162
* Clarify test casesbogdanvlviv2018-07-151-1/+1
| | | | | | | | | | | | | Remove extra stub of `ActiveRecord::Base::connection` in `activerecord/test/cases/tasks/mysql_rake_test.rb`. Remove extra stub of `File::exist?` in `activerecord/test/cases/tasks/sqlite_rake_test.rb`. `ActiveRecord::Base::establish_connection` shouldn't return `true` in test cases. Related to https://github.com/rails/rails/pull/33337.
* Stub with Minitest instead of Mochautilum2018-07-151-84/+143
| | | | Step 4 in #33162
* Replace shallow mocks with Ruby classesutilum2018-07-101-5/+8
| | | | | | | While preparing this I realised that some stubbed returns values serve no purpose, so this patch drops those as well. Step 3 in #33162
* Reduce mocking by testing value instead of method callutilum2018-07-091-4/+1
| | | | Step 2 in #33162
* Remove unnecessary Mocha stubsutilum2018-07-071-15/+5
| | | | | | Step 1 in #33162 [utilum + bogdanvlviv]
* assert_called_withutilum2018-04-261-30/+74
|
* 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-301-0/+10
| | | | | | | | | | | | | | | | | 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-191-0/+2
|
* Revert "Merge pull request #29540 from kirs/rubocop-frozen-string"Matthew Draper2017-07-021-1/+0
| | | | | This reverts commit 3420a14590c0e6915d8b6c242887f74adb4120f9, reversing changes made to afb66a5a598ce4ac74ad84b125a5abf046dcf5aa.
* Enforce frozen string in RubocopKir Shatrov2017-07-011-0/+1
|
* 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.
* 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.
* Merge pull request #27437 from kirs/structure-load-dump-flagsKasper Timm Hansen2016-12-291-1/+38
|\ | | | | Make ActiveRecord structure load/dump configurable
| * Make ActiveRecord structure load/dump configurableKir Shatrov2016-12-221-1/+38
| | | | | | | | | | | | | | | | 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-261-3/+3
|/
* normalizes indentation and whitespace across the projectXavier Noria2016-08-061-225/+225
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-6/+6
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-42/+42
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* 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.
* Fix isolated test failures due to referencing ↵Jeremy Daer2016-04-181-0/+1
| | | | ActiveRecord::Tasks::DatabaseAlreadyExists before another test happened to make it available
* Added notice when a database is successfully created or dropped.bogdanvlviv2016-04-171-4/+29
|
* Fix rake db:structure:dump on Postgres when multiple schemas are used.Nick Muerdter2015-11-191-2/+2
| | | | | | | | | | | | | | | | | | If postgresql is being used and there are multiple schemas listed on the `schema_search_path`, then `structure.sql` dumps (triggered by `rake db:structure:dump` or `config.active_record.schema_format = :sql`) began failing in Rails 4.2.5. This is due to the changes made in https://github.com/rails/rails/pull/17885 The problem is that multiple schemas were getting getting passed to `Kernel.system` as a single, space delimited string argument (for example, "--schema=foo --schema=bar"). However, with the updated array style of calling `Kernel.system`, these need to be passed as separate arguments (for example, "--schema=foo", "--schema=bar"). If they get passed as a single string, then the underlying pg_dump program isn't sure how to interpret that single argument and you'll get an error reporting: "pg_dump: No matching schemas were found"
* Exit with non-zero status when db:create failsJay Hayes2015-10-201-1/+1
| | | | | | | | | | | * 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`. * :warning: 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.
* Merge pull request #21931 from paul/bugfix/remove-deprecated-pg_dump-flagYves Senn2015-10-121-4/+4
| | | | Remove deprecated pg_dump -i flag
* Add run_cmd class method to ActiveRecord::Tasks::DatabaseTasksstarbelly2015-08-011-6/+6
| | | | | | | | | | - Added run_cmd() class method to dry up Kernel.system() messages within this namespace and avoid shell expansion by passing a list of arguments instead of a string - Update structure_dump, structure_load, and related tests units to pass a list of params instead of using a string to avoid shell expansion
* Merge pull request #19503 from jasoncodes/no-psqlrcYves Senn2015-03-251-2/+2
| | | | Avoid loading user's psqlrc when loading test structure
* Add config.active_record.dump_schemas.Ryan Wallace2015-03-171-6/+39
| | | | | | | Fixes db:structure:dump when using schema_search_path and PostgreSQL extensions. Closes #17157.
* tests, run adapter specific rake tests only for the right adapter.Yves Senn2014-07-241-0/+2
|
* Revert "Properly require database tasks so we have access to the raised ↵Rafael Mendonça França2013-11-191-1/+0
| | | | | | | | constant" This reverts commit fbcd46b1a0d255a34d29caa77bbd31c287446333. This is not needed anymore. See 7280965
* Revert "Explicitly exit with status "1" for create and drop failures"Rafael Mendonça França2013-11-191-6/+2
| | | | | | | | | | This reverts commit 22f80ae57b26907f662b7fd50a7270a6381e527e. See https://github.com/rails/rails/commit/22f80ae57b26907f662b7fd50a7270a6381e527e#commitcomment-4640676 Conflicts: activerecord/CHANGELOG.md
* Properly require database tasks so we have access to the raised constantCarlos Antonio da Silva2013-11-171-0/+1
| | | | Fix travis failures.
* Merge pull request #12531 from iamvery/database-tasks-exit-statusRafael Mendonça França2013-11-151-2/+6
|\ | | | | | | | | | | | | Explicitly exit with status "1" for create and drop task failures Conflicts: activerecord/CHANGELOG.md
| * Explicitly exit with status "1" for create and drop failuresJay Hayes2013-11-111-2/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * A non-zero exit status allows subsequent shell commands to be chained together such as: `rake db:reset test:prepare && rspec && cap deploy` (if you're feeling brave :) * Any exceptions raised during the `create` and `drop` tasks are caught in order to print a "pretty" message to the user. Unfortunately doing so prevents rake from aborting with a non-zero exit status to the shell. * Therefore we re-raise the exceptions after the "pretty" message and re-catch them in the task. * From the task we explicitly exit with a non-zero status. This method was chosen (rather than just letting rake fail from the exception) so that the backtrace is suppressed and the output to stderr is unchanged. * Update activerecord CHANGELOG
* | More Warnings removed for ruby trunkArun Agrawal2013-11-011-1/+1
| | | | | | | | Same as 4d4ff531b8807ee88a3fc46875c7e76f613956fb
* | Fix loading a sql structure file on postgres when the file's path has ↵Kevin Mook2013-10-211-0/+7
|/ | | | whitespace in it
* Mute psql output when running rake db:schema:loadGodfrey Chan2013-04-301-1/+1
|
* Fix tiny problem: change method order for consistency and fix wrong method name.kennyj2013-04-031-1/+1
|
* Bring back "database already exists" messages when running rake tasksCarlos Antonio da Silva2013-01-121-0/+10
| | | | | | | | | | When running tasks such "rake db:setup", instead of showing messages like "db_development already exists", it was showing a big stack trace and a message "Couldn't create database for ..." with the configuration options, a very confusing message with a big trace. This brings back the functionality present in 3-2, showing the same message.
* Unify the collation API for the database adptersRafael Mendonça França2012-07-011-4/+4
|
* Extract collation tasks to database tasks.kennyj2012-07-011-0/+18
|
* Support collate and ctype on the PostgreSQL.kennyj2012-06-291-0/+8
|