aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test
Commit message (Collapse)AuthorAgeFilesLines
...
* | | | | | no more require minitest mockGaurav Sharma2015-08-273-3/+0
| | | | | |
* | | | | | Merge pull request #21386 from ronakjangir47/remove_dupsRafael Mendonça França2015-08-264-4/+0
|\ \ \ \ \ \ | | | | | | | | | | | | | | Removed duplicate requires
| * | | | | | Removed duplicate require ‘models/computer’Ronak Jangir2015-08-264-4/+0
| | | | | | |
* | | | | | | Fix the unused variable warningakihiro172015-08-261-1/+0
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This fixes the following warning. ```ruby warning: assigned but unused variable - index_definition ```
* | | | | | Merge pull request #21377 from ronakjangir47/remove_mocha_active_recordKasper Timm Hansen2015-08-2512-119/+153
|\ \ \ \ \ \ | | | | | | | | | | | | | | Removed mocha from Active Record Part 1
| * | | | | | Removed mocha from Active Record Part 1Ronak Jangir2015-08-2512-119/+153
| | | | | | |
* | | | | | | Make `change_column_default` to workyui-knk2015-08-251-0/+33
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is fix of #20018 which removes `change_column_default` from array, so `CommandRecorder#method_missing` catches `change_column_default` and @delegate's method is called. This PR * fix this bug * define `ReversibleAndIrreversibleMethods` const making clear which this array means to prevent these miss
* | | | | | | Merge pull request #21342 from yui-knk/test/add_assert_methodRafael Mendonça França2015-08-241-1/+1
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Add `assert_nothing_raised` to make clear test case perpose
| * | | | | | | Add `assert_nothing_raised` to make clear test case perposeyui-knk2015-08-231-1/+1
| | | | | | | |
* | | | | | | | Further fix failing tests caused by #21350Sean Griffin2015-08-241-0/+1
| | | | | | | |
* | | | | | | | Fix failing tests caused by #21350Sean Griffin2015-08-241-0/+1
| |/ / / / / / |/| | | | | |
* | | | | | | Only nullify persisted has_one target associationsAgis-2015-08-244-0/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Since after 87d1aba3c `dependent: :destroy` callbacks on has_one assocations run *after* destroy, it is possible that a nullification is attempted on an already destroyed target: class Car < ActiveRecord::Base has_one :engine, dependent: :nullify end class Engine < ActiveRecord::Base belongs_to :car, dependent: :destroy end > car = Car.create! > engine = Engine.create!(car: car) > engine.destroy! # => ActiveRecord::ActiveRecordError: cannot update a > destroyed record In the above case, `engine.destroy!` deletes `engine` and *then* triggers the deletion of `car`, which in turn triggers a nullification of `engine.car_id`. However, `engine` is already destroyed at that point. Fixes #21223.
* | | | | | | Remove test helper method to inside test methodyui-knk2015-08-231-5/+1
|/ / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Remove `MigrationTest#connection` and write `ActiveRecord::Base.connection` directly to test, because `MigrationTest#connection` is only used in `test_migration_instance_has_connection`.
* | | | | | uniqueness validation raises error for persisted record without pk.Yves Senn2015-08-201-0/+23
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Closes #21304. While we can validate uniqueness for record without primary key on creation, there is no way to exclude the current record when updating. (The update itself will need a primary key to work correctly).
* | | | | | Add a native JSON data type support in MySQLRyuta Kamizono2015-08-181-0/+172
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As of MySQL 5.7.8, MySQL supports a native JSON data type. Example: create_table :json_data_type do |t| t.json :settings end
* | | | | | Merge pull request #21284 from prakashlaxkar/argument_error_testsYves Senn2015-08-181-0/+8
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | Correct error message in Standard American english and add a test cas…
| * | | | | | Correct error message in Standard American english and add a test case for ↵prakash2015-08-181-0/+13
|/ / / / / / | | | | | | | | | | | | | | | | | | the same.
* | | | | | Merge pull request #19683 from tristang/require-option-for-counter-cacheRafael Mendonça França2015-08-136-5/+48
|\ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | Require explicit counter_cache option for has_many
| * | | | | | Add tests for associations without counter_cacheTristan Gamilis2015-04-094-0/+43
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Assert that counter_cache behaviour is not used on belongs_to or has_many associations if the option is not given explicitly.
| * | | | | | Require explicit counter_cache option for has_manyTristan Gamilis2015-04-072-5/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously has_many associations assumed a counter_cache was to be used based on the presence of an appropriately named column. This is inconsistent, since the inverse belongs_to association will not make this assumption. See issues #19042 #8446. This commit checks for the presence of the counter_cache key in the options of either the has_many or belongs_to association as well as ensuring that the *_count column is present.
* | | | | | | Merge pull request #19770 from vngrs/prevent_duplicated_where_clausesRafael Mendonça França2015-08-132-0/+13
|\ \ \ \ \ \ \ | | | | | | | | | | | | | | | | Prevent duplicating `where` clauses
| * | | | | | | Prevent duplicating `where` clauses when model is extended from an abstract ↵Mehmet Emin İNAÇ2015-04-152-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | class Fixes #19528 fix for mysql2 test better test
* | | | | | | | descriptive error message when fixtures contian a missing column.Yves Senn2015-08-132-0/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Closes #21201.
* | | | | | | | use `assert_not` instead of `refute` as mentioned in our guides.Yves Senn2015-08-136-21/+21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | As described in the "Follow Coding Conventions" section in our contribution guide (http://edgeguides.rubyonrails.org/contributing_to_ruby_on_rails.html#follow-the-coding-conventions) we favor `assert_not` over `refute`. While we don't usually make stylistic changes on it's own I opted to do it in this case. The reason being that test cases are usually copied as a starting point for new tests. This results in a spread of `refute` in files that have been using it already.
* | | | | | | | Skip statement cache on through association readerRafael Mendonça França2015-08-128-9/+110
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | If the through class has default scopes we should skip the statement cache. Closes #20745.
* | | | | | | | Merge pull request #17885 from starbelly/patch-1Yves Senn2015-08-111-6/+6
|\ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add method to run command-line db apps Conflicts: activerecord/CHANGELOG.md
| * | | | | | | | 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 #21165 from manlon/masterRafael Mendonça França2015-08-114-0/+27
|\ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | use correct DB connection for generated HABTM table
| * | | | | | | | | use correct DB connection for generated HABTM tableMatt Hanlon2015-08-074-0/+27
| | | | | | | | | |
* | | | | | | | | | Remove XML Serialization from core.Zachary Scott2015-08-072-448/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This includes the following classes: - ActiveModel::Serializers::Xml - ActiveRecord::Serialization::XmlSerializer
* | | | | | | | | | Add ActiveRecord::Relation#in_batchesSina Siadat2015-08-071-2/+230
|/ / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `in_batches` yields Relation objects if a block is given, otherwise it returns an instance of `BatchEnumerator`. The existing `find_each` and `find_in_batches` methods work with batches of records. The new API allows working with relation batches as well. Examples: Person.in_batches.each_record(&:party_all_night!) Person.in_batches.update_all(awesome: true) Person.in_batches.delete_all Person.in_batches.map do |relation| relation.delete_all sleep 10 # Throttles the delete queries end
* | | | | | | | | Merge pull request #20459Sean Griffin2015-08-061-0/+93
|\ \ \ \ \ \ \ \ \
| * | | | | | | | | Add missing data types for ActiveRecord migrationsMehmet Emin İNAÇ2015-06-081-0/+93
| | | | | | | | | |
* | | | | | | | | | Merge pull request #21092 from vngrs/use_memoization_for_ids_readerRafael Mendonça França2015-08-061-0/+8
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | Use memoization for collection associations ids reader
| * | | | | | | | | | Use memoization for collection associations ids readerMehmet Emin İNAÇ2015-08-031-0/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Fixes #21082 remove extra space
* | | | | | | | | | | Fix ambiguous argument warningMehmet Emin İNAÇ2015-08-021-1/+1
|/ / / / / / / / / / | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | encapsulate all arguments
* | | | | | | | | | Merge pull request #20884Sean Griffin2015-08-011-0/+70
|\ \ \ \ \ \ \ \ \ \ | |_|/ / / / / / / / |/| | | | | | | | | | | | | | | | | | | Add #cache_key to ActiveRecord::Relation.
| * | | | | | | | | Add #cache_key to ActiveRecord::Relation.Alberto F. Capel2015-07-201-0/+70
| | | | | | | | | |
* | | | | | | | | | Merge pull request #20849 from vngrs/misleading_nested_exceptionsRafael Mendonça França2015-07-273-4/+12
|\ \ \ \ \ \ \ \ \ \ | | | | | | | | | | | | | | | | | | | | | | Fix misleading errors for has_one through relations
| * | | | | | | | | | Fix misleading errors for has_one through relationsMehmet Emin İNAÇ2015-07-223-4/+12
| | | | | | | | | | |
* | | | | | | | | | | Remove @connection instance variable only when definedYasuo Honda2015-07-261-2/+2
| | | | | | | | | | |
* | | | | | | | | | | Properly allow uniqueness validations on primary keys.Sean Griffin2015-07-251-0/+19
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This is an alternate implementation of #20966. [Sean Griffin & presskey]
* | | | | | | | | | | `destroy` shouldn't raise when child associations fail to saveSean Griffin2015-07-241-0/+30
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Deep down in the association internals, we're calling `destroy!` rather than `destroy` when handling things like `dependent` or autosave association callbacks. Unfortunately, due to the structure of the code (e.g. it uses callbacks for everything), it's nearly impossible to pass whether to call `destroy` or `destroy!` down to where we actually need it. As such, we have to do some legwork to handle this. Since the callbacks are what actually raise the exception, we need to rescue it in `ActiveRecord::Callbacks`, rather than `ActiveRecord::Persistence` where it matters. (As an aside, if this code wasn't so callback heavy, it would handling this would likely be as simple as changing `destroy` to call `destroy!` instead of the other way around). Since we don't want to lose the exception when `destroy!` is called (in particular, we don't want the value of the `record` field to change to the parent class), we have to do some additional legwork to hold onto it where we can use it. Again, all of this is ugly and there is definitely a better way to do this. However, barring a much more significant re-architecting for what I consider to be a reletively minor improvement, I'm willing to take this small hit to the flow of this code (begrudgingly).
* | | | | | | | | | | Remove ivar only when definedAkira Matsuda2015-07-241-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | this fixes a failing test case
* | | | | | | | | | | Rename the enum_{prefix,suffix} options to _{prefix,suffix}Robin Dupret2015-07-231-4/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This makes it more clear that they are reserved keywords and also it seems less redundant as the line already starts with the call to the `enum` method.
* | | | | | | | | | | fix rails testsMehmet Emin İNAÇ2015-07-211-1/+1
|/ / / / / / / / / /
* | | | | | | | | | Deprecate and rename the keys for association restrict_dependent_destroyRoque Pinel2015-07-202-0/+39
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously `has_one` and `has_many` associations were using the `one` and `many` keys respectively. Both of these keys have special meaning in I18n (they are considered to be pluralizations) so by renaming them to `has_one` and `has_many` we make the messages more explicit and most importantly they don't clash with linguistical systems that need to validate translation keys (and their pluralizations). The `:'restrict_dependent_destroy.one'` key should be replaced with `:'restrict_dependent_destroy.has_one'`, and `:'restrict_dependent_destroy.many'` with `:'restrict_dependent_destroy.has_many'`. [Roque Pinel & Christopher Dell]
* | | | | | | | | | Ensure that microsecond precision is only used for version of mysql that ↵Jori Hardman2015-07-203-1/+37
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | support it. Fixes #19711
* | | | | | | | | | Fix minor typo in test nameSean Griffin2015-07-201-1/+1
| | | | | | | | | |
* | | | | | | | | | Fix state being carried over from previous transactionRoque Pinel2015-07-201-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This clears the transaction record state when the transaction finishes with a `:committed` status. Considering the following example where `name` is a required attribute. Before we had `new_record?` returning `true` for a persisted record: ```ruby author = Author.create! name: 'foo' author.name = nil author.save # => false author.new_record? # => true ```