aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/base_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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-3/+3
| | | | | | | | Style/SpaceBeforeBlockBraces Style/SpaceInsideBlockBraces Style/SpaceInsideHashLiteralBraces Fix all violations in the repository.
* Pass along original attribute to save later recursionAaron Patterson2016-08-141-0/+7
| | | | Fixes #26122
* Fix broken alignments caused by auto-correct commit 411ccbdRyuta Kamizono2016-08-101-1/+2
| | | | Hash syntax auto-correcting breaks alignments. 411ccbdab2608c62aabdb320d52cb02d446bb39c
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+1
|
* remove redundant curlies from hash argumentsXavier Noria2016-08-061-12/+10
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-53/+53
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-123/+123
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Removed a forgotten `with_exclusive_scope` test:Edouard CHIN2016-06-241-6/+0
| | | | - `with_exclusive_scope` was removed in this commit d242e467819a428ad7e302968e4c9fa1e26d9326
* Remove unnecessary model requiresJon Moss2016-06-101-2/+0
|
* `ActiveRecord::Base#hash` should differ between classesSean Griffin2016-05-311-0/+4
| | | | | | | | Prior to this change, we would get collisions if Active Record objects of different classes with the same ID were used as keys of the same hash. It bothers me slightly that we have to allocate inside of this method, but Ruby doesn't provide any way to hash multiple values without allocation
* Support for unified Integer class in Ruby 2.4+Jeremy Daer2016-05-181-2/+2
| | | | | | | | Ruby 2.4 unifies Fixnum and Bignum into Integer: https://bugs.ruby-lang.org/issues/12005 * Forward compat with new unified Integer class in Ruby 2.4+. * Backward compat with separate Fixnum/Bignum in Ruby 2.2 & 2.3. * Drops needless Fixnum distinction in docs, preferring Integer.
* Revert "Deprecate table names containing dots"Sean Griffin2016-03-311-8/+0
| | | | | | This reverts commit 7b82e1c77b48cb351da4e0ed6ea0bac806d4925c. This would have removed the ability to reference a schema when using PG
* Deprecate table names containing dotsSean Griffin2016-03-311-0/+8
| | | | | | | | Dots have special meaning in most backends (e.g. everything except SQLite3), as well as most methods that work with table or column names. This isn't something that we ever explicitly supported, but there's at least one case of somebody using this (see #24367), so we'll go through a deprecation cycle as normal.
* Typos in AR testsAkira Matsuda2016-02-031-1/+1
|
* Active scopes apply to child classes, though not parents/siblingsMatthew Draper2016-01-121-2/+3
| | | | | | | While the commit message (and changelog example) in 5e0b555b453ea2ca36986c111512627d806101e7 talked about sibling classes, the added test had a child ignore its parent's scoping, which seems less reasonable.
* Fixes LoggerSilence#silence threadsafetyCarl P. Corliss2015-12-231-0/+1
| | | | | | | - uses instance defined level if no custom local log level defined - Keeps track of local log level per [ thread + object-instance ] - prevents memory leakage by removing local level hash key/value on #silence method exit - avoids the use of Thread local variables
* Remove legacy mysql adapterRyuta Kamizono2015-12-211-1/+0
| | | | Follow up to #22642.
* Merge pull request #22653 from matthewd/find_array_orderedMatthew Draper2015-12-181-1/+2
|\ | | | | | | ActiveRecord::Base#find(array) returning result in the same order as the array passed
| * [#20338] improving implementation, fixing and adding some more specsMiguel Grazziotin2015-06-031-1/+2
| |
* | Remove legacy mysql adapterAbdelkader Boudih2015-12-171-1/+1
| |
* | Fix test failures on WindowsSean Griffin2015-12-161-4/+12
| | | | | | | | | | | | | | Unlike unix, the TZ variable on Windows does not look at a database. It is always expected to be in the form {Standard Time Abbreviation}{UTC-Offset}{Daylight Time Abbriviation}. This changes the relevant tests to use the Windows form when run from Windows.
* | Use a bind param for `LIMIT` and `OFFSET`Sean Griffin2015-12-141-6/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently generate an unbounded number of prepared statements when `limit` or `offset` are called with a dynamic argument. This changes `LIMIT` and `OFFSET` to use bind params, eliminating the problem. `Type::Value#hash` needed to be implemented, as it turns out we busted the query cache if the type object used wasn't exactly the same object. This drops support for passing an `Arel::Nodes::SqlLiteral` to `limit`. Doing this relied on AR internals, and was never officially supported usage. Fixes #22250.
* | Deprecate limit strings with commasSean Griffin2015-12-141-3/+7
| | | | | | | | | | | | | | | | | | | | Some backends allow `LIMIT 1,2` as a shorthand for `LIMIT 1 OFFSET 2`. Supporting this in Active Record massively complicates using bind parameters for limit and offset, and it's trivially easy to build an invalid SQL query by also calling `offset` on the same `Relation`. This is a niche syntax that is only supported by a few adapters, and can be trivially worked around by calling offset explicitly.
* | add `ActiveRecord::Base.has_attribute?`Yves Senn2015-12-021-0/+13
| | | | | | | | `has_attribute?` method to check wether a given attribute has been defined.
* | Require only necessary concurrent-ruby classes.Jerry D'Antonio2015-11-041-1/+1
| |
* | Move some AR test cases to inheritance_test.rbyui-knk2015-10-311-79/+0
| | | | | | | | | | | | | | | | These methods are defined in inheritance.rb * `abstract_class?` * `descends_from_active_record?` * `compute_type`
* | Fix typo in ignored_columns test [skip ci]Jon Atack2015-09-241-1/+1
| | | | | | | | Follow-up to #21720.
* | Implement ActiveRecord::Base.ignored_columnsJean Boussier2015-09-241-0/+18
| |
* | Don't attempt to specify datetime precision unless supportedSean Griffin2015-09-231-1/+1
| | | | | | | | | | | | | | | | | | Specifically, versions of MySQL prior to 5.6 do not support this, which is what's used on Travis by default. The method `mysql_56?` appeared to only ever be used to conditionally apply subsecond precision, so I've generalized it and used it more liberally. This should fix the test failures caused by #20317
* | File encoding is defaulted to utf-8 in Ruby >= 2.1Akira Matsuda2015-09-181-2/+0
| |
* | Removed mocha from Active Record Part 2Ronak Jangir2015-09-161-10/+13
| |
* | Respect scale of the column in the Decimal typeRafael Mendonça França2015-09-011-0/+28
| | | | | | | | [Rafael Mendonça França + Jean Boussier]
* | Replaced `ActiveSupport::Concurrency::Latch` with concurrent-ruby.Jerry D'Antonio2015-07-131-7/+7
|/ | | | | | | | | | The concurrent-ruby gem is a toolset containing many concurrency utilities. Many of these utilities include runtime-specific optimizations when possible. Rather than clutter the Rails codebase with concurrency utilities separate from the core task, such tools can be superseded by similar tools in the more specialized gem. This commit replaces `ActiveSupport::Concurrency::Latch` with `Concurrent::CountDownLatch`, which is functionally equivalent.
* deprecate `Relation#uniq` use `Relation#distinct` instead.Yves Senn2015-05-261-6/+4
| | | | | | | | | See #9683 for the reasons we switched to `distinct`. Here is the discussion that triggered the actual deprecation #20198. `uniq`, `uniq!` and `uniq_value` are still around. They will be removed in the next minor release after Rails 5.
* tests, sequences are derived from the base class.Yves Senn2015-03-061-7/+10
| | | | | Using a subclass to check the sequence name does not work in that case. The sequence name will be calucalted based on the base class.
* tests, remove side effects on `Joke` during `base_test.rb`.Yves Senn2015-03-061-23/+28
| | | | prompted by #19221.
* Do not test, document or use a private API methodRafael Mendonça França2015-02-201-1/+0
| | | | These methods are nodoc so we should not document them.
* Rm `Type#type_cast`Sean Griffin2015-02-171-1/+1
| | | | | | | | | This helper no longer makes sense as a separate method. Instead I'll just have `deserialize` call `cast` by default. This led to a random infinite loop in the `JSON` pg type, when it called `super` from `deserialize`. Not really a great way to fix that other than not calling super, or continuing to have the separate method, which makes the public API differ from what we say it is.
* Allow a symbol to be passed to `attribute`, in place of a type objectSean Griffin2015-02-061-2/+2
| | | | | | | | | | | | | | | | | | The same is not true of `define_attribute`, which is meant to be the low level no-magic API that sits underneath. The differences between the two APIs are: - `attribute` - Lazy (the attribute will be defined after the schema has loaded) - Allows either a type object or a symbol - `define_attribute` - Runs immediately (might get trampled by schema loading) - Requires a type object This was the last blocker in terms of public interface requirements originally discussed for this feature back in May. All the implementation blockers have been cleared, so this feature is probably ready for release (pending one more look-over by me).
* Removed magic comments # encoding: utf-8 , since its default from ruby 2.0 ↵Vipul A M2015-02-031-1/+0
| | | | onwards.
* Add firebird support to test suiteRay Zane2015-01-051-1/+2
|
* Correctly handle multiple attribute method prefix/suffixes which matchSean Griffin2014-12-041-0/+10
| | | | | | | | | Active Record defines `attribute_method_suffix :?`. That suffix will match any predicate method when the lookup occurs in Active Model. This will make it incorrectly decide that `id_changed?` should not exist, because it attempts to determine if the attribute `id_changed` is present, rather than `id` with the `_changed?` suffix. Instead, we will look for any correct match.
* tests, move pg geometric tests out of `base_test`.Yves Senn2014-12-021-87/+0
|
* Build fix when running in isolationArun Agrawal2014-11-141-0/+1
| | | | | `Computer` class needs to be require See #17217 for more details
* Add a test case for range type castingSean Griffin2014-11-011-0/+4
| | | | | We support this behavior, but have no tests which assert that type casting actually occurs.
* Treat strings greater than int max value as out of rangeSean Griffin2014-10-311-1/+0
| | | | | | | | | | | Sufficiently large integers cause `find` and `find_by` to raise `StatementInvalid` instead of `RecordNotFound` or just returning `nil`. Given that we can't cast to `nil` for `Integer` like we would with junk data for other types, we raise a `RangeError` instead, and rescue in places where it would be highly unexpected to get an exception from casting. Fixes #17380
* 💣Sean Griffin2014-10-281-1/+4
| | | | We were relying on hash inequality in tests
* Fixed find_by("sql fragment without bindings") on masterGodfrey Chan2014-08-251-14/+0
| | | | | | | | | | | * Also duplicated find_by tests from relations_test.rb to finder_test.rb now that we have a completely different implementation on the class (in core.rb with AST caching stuff). * Also removed a (failing) test that used mocks. Now that we have tests for the behavior, there's no point having another test that tests the implementation (that it delegates). Further, what the test was implying is nolonger true with the current implementation, because Class.find_by is a real method now.
* Dont swallow errors when bad alias_methodArthur Neves2014-06-241-2/+20
|