aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/tasks/mysql_rake_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* `assert_called_with` should require `args` argumentbogdanvlviv2018-10-251-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | There are two main reasons why `assert_called_with` should require `args` argument: 1) If we want to assert that some method should be called and we don't need to check with which arguments it should be called then we should use `assert_called`. 2) `assert_called_with` without `args` argument doesn't assert anything! ```ruby assert_called_with(@object, :increment) do @object.decrement end ``` It causes false assertions in tests that could cause regressions in the project. I found this bug by working on [minitest-mock_expectations](https://github.com/bogdanvlviv/minitest-mock_expectations) gem. This gem is an extension for minitest that provides almost the same method call assertions. I was wondering whether you would consider adding "minitest-mock_expectations" to `rails/rails` instead of private `ActiveSupport::Testing::MethodCallAssertions` module. If yes, I'll send a patch - https://github.com/bogdanvlviv/rails/commit/a970ecc42c3a9637947599f2c13e3762e4b59208
* Stub with Minitest and test with MethodCallAssertionsutilum2018-08-131-8/+16
|
* Replace permissive Mocha expectationsutilum2018-07-221-9/+20
| | | | | | | | | | | | | | | | | | | | | | | | | 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-28/+33
| | | | | | | | | | 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-8/+6
| | | | | | | | | | | | | 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-71/+120
| | | | Step 4 in #33162
* Fix stubbed methods in test casesbogdanvlviv2018-07-101-1/+1
| | | | | | | | | | Remove returning of `false` value for stubbed `lock_thread=` methods since there aren't any needs in it. Remove unnecessary returning of `true` for stubbed `drop_database` method. Follow up #33309. Related to #33162, #33326.
* Replace shallow mocks with Ruby classesutilum2018-07-101-6/+6
| | | | | | | While preparing this I realised that some stubbed returns values serve no purpose, so this patch drops those as well. Step 3 in #33162
* Remove unnecessary Mocha stubsutilum2018-07-071-7/+3
| | | | | | Step 1 in #33162 [utilum + bogdanvlviv]
* assert_called_withutilum2018-04-261-24/+47
|
* 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
* 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
|
* 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 MySQL structure dumpGuillermo Iguaran2017-05-151-0/+16
|
* 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).
* Remove duplicated testutilum2017-01-021-8/+0
| | | | | b8f74860b61782e3b949ade3bb51bff40899e89b provided a nicer version of `#test_structure_load` but the old version was not removed.
* Merge pull request #27437 from kirs/structure-load-dump-flagsKasper Timm Hansen2016-12-291-0/+40
|\ | | | | Make ActiveRecord structure load/dump configurable
| * Make ActiveRecord structure load/dump configurableKir Shatrov2016-12-221-0/+40
| | | | | | | | | | | | | | | | 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-259/+259
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-5/+5
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-45/+45
| | | | | 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
| |
* | 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/+36
|/
* Remove legacy mysql adapterRyuta Kamizono2015-12-211-75/+72
| | | | Follow up to #22642.
* Remove legacy mysql adapterAbdelkader Boudih2015-12-171-12/+12
|
* Fix test_database_created_by_root of mysqlyui-knk2015-11-021-1/+1
| | | | | | `DEFAULT_CHARSET` and `DEFAULT_COLLATION` in `MySQLDatabaseTasks` was changed by 322068fe85278ea26e26da6dfd7c5612dab15a72. This test case also should be changed.
* Remove `DEFAULT_CHARSET` and `DEFAULT_COLLATION` in `MySQLDatabaseTasks`Ryuta Kamizono2015-11-021-13/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This reverts commit f6ca7e4e75408bc42f515fc7206d6c6ff0dce7c6. The default collation of utf8 in MySQL is the `utf8_general_ci`, and this should not be changed. This is because, the better collation in the all locales is not exists, optimal collation in own application is not known other than themselves. The `utf8_unicode_ci` is known as Japanese killer in Japan, there are serious impacts in search of Japanese. MySQL implements the `utf8_unicode_ci` according to the Unicode Collation Algorithm (UCA) described at http://www.unicode.org/reports/tr10/, but the `utf8_unicode_ci` have only partial support for the UCA, only primary level key comparison implemented (also known as L1 (Base characters) comparison). Because L1 (Base characters) comparison does not distinguish between the presence or absence of the accent, if distinction of the accent is important there is a serious impact (e.g. Japanese). Example: ``` > SHOW CREATE TABLE `dicts`\G *************************** 1. row *************************** Table: dicts Create Table: CREATE TABLE `dicts` ( `word` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL, `meaning` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci 1 row in set (0.00 sec) > INSERT INTO `dicts` VALUES ('ハハ', 'mother'), ('パパ', 'father'); Query OK, 2 rows affected (0.00 sec) > SELECT * FROM `dicts` WHERE `word` = 'ハハ'; +--------+---------+ | word | meaning | +--------+---------+ | ハハ | mother | | パパ | father | +--------+---------+ 2 rows in set (0.00 sec) > CREATE UNIQUE INDEX `unique_index_word` ON `dicts`(`word`); ERROR 1062 (23000): Duplicate entry 'ハハ' for key 'unique_index_word' ``` We should omit the collation entirely rather than providing a default. Then the choice is the responsibility of the server and MySQL distribution.
* Merge pull request #20569 from theSteveMitchell/masterYves Senn2015-09-221-6/+8
|\ | | | | | | Check mysql structure_load for errors
| * Check response of structure_load for mysql_database_tasks and make ↵Steve Mitchell2015-09-181-3/+16
|/ | | | structure_dump consistent
* Changed mysqldump to include sprocs and functionsJonathan Worek2015-05-221-4/+4
|
* Add full set of MySQL CLI options to support SSL authentication when using ↵Alex Coomans2015-05-121-1/+10
| | | | db:structure dump and load
* tests, run adapter specific rake tests only for the right adapter.Yves Senn2014-07-241-0/+2
|
* build fix, fix error introduced with 091b246bb0111357edbb9703ea342a944b04deb6Yves Senn2014-07-241-2/+2
| | | | | | | | | | | | | | Fixes the following issue: 1) Failure: ActiveRecord::MySQLPurgeTest#test_establishes_connection_to_test_database [test/cases/tasks/mysql_rake_test.rb:200]: not all expectations were satisfied unsatisfied expectations: - expected exactly once, not yet invoked: ActiveRecord::Base.establish_connection(:test) satisfied expectations: - allowed any number of times, invoked once: #<Mock:0x2349430>.recreate_database(any_parameters) - allowed any number of times, invoked once: ActiveRecord::Base.establish_connection(any_parameters) - allowed any number of times, invoked once: ActiveRecord::Base.connection(any_parameters)
* Active Record tests still depend on `capture`. Let's keep it for now.Yves Senn2014-07-161-19/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is a follow-up to 3121412 /cc @rafaelfranca This will remove deprecation warnings from the PostgreSQL suite: ``` DEPRECATION WARNING: #capture(stream) is deprecated and will be removed in the next release. (called from capture at /Users/senny/Projects/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:89) /Users/senny/Projects/rails/activesupport/lib/active_support/core_ext/kernel/reporting.rb:89:in `capture' /Users/senny/Projects/rails/activerecord/test/cases/adapters/postgresql/composite_test.rb:73:in `ensure_warning_is_issued' /Users/senny/Projects/rails/activerecord/test/cases/adapters/postgresql/composite_test.rb:48:in `test_column' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest/test.rb:106:in `block (3 levels) in run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest/test.rb:204:in `capture_exceptions' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest/test.rb:103:in `block (2 levels) in run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest/test.rb:256:in `time_it' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest/test.rb:102:in `block in run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:317:in `on_signal' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest/test.rb:276:in `with_info_handler' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest/test.rb:101:in `run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:759:in `run_one_method' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:293:in `run_one_method' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:287:in `block (2 levels) in run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:286:in `each' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:286:in `block in run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:317:in `on_signal' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:306:in `with_info_handler' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:285:in `run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:149:in `block in __run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:149:in `map' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:149:in `__run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:126:in `run' /Users/senny/Projects/rails/.bundle/gems/minitest-5.3.3/lib/minitest.rb:55:in `block in autorun' ```
* Keep quietly and capture undeprecated on your suiteRafael Mendonça França2014-07-151-0/+19
|
* 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-3/+1
| | | | | | | | | | 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-1/+3
|\ | | | | | | | | | | | | 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-1/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * 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
* | Don't skip tests if we don't need to.Rafael Mendonça França2013-11-081-75/+74
| | | | | | | | | | | | | | We can conditional define the tests depending on the adapter or connection. Lets keep the skip for fail tests that need to be fixed.
* | Convert Fixnum into String the port number in MySQLKenta Okamoto2013-10-181-0/+9
|/
* `rake db:create` does not change permissions of root user.Yves Senn2013-03-171-2/+18
| | | | | | | | Closes #8079. I had to rework some of the tests because the mock allowed any arguments for `connection.exeucte`. I think this is very dangerous as there could anything be executed without the tests noticing it.