aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/base_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Merge pull request #15593 from sgrif/sg-attributeRafael Mendonça França2014-06-131-4/+3
|\ | | | | Introduce an Attribute object to handle the type casting dance
| * Introduce an Attribute object to handle the type casting danceSean Griffin2014-06-131-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | There's a lot more that can be moved to these, but this felt like a good place to introduce the object. Plans are: - Remove all knowledge of type casting from the columns, beyond a reference to the cast_type - Move type_cast_for_database to these objects - Potentially make them mutable, introduce a state machine, and have dirty checking handled here as well - Move `attribute`, `decorate_attribute`, and anything else that modifies types to mess with this object, not the columns hash - Introduce a collection object to manage these, reduce allocations, and not require serializing the types
* | Add a test to ensure we don't get a performance regression on #hashSean Griffin2014-06-121-0/+7
|/
* Rename `type_cast` to `type_cast_from_database`Sean Griffin2014-06-091-1/+1
| | | | | | | | In some cases there is a difference between the two, we should always be doing one or the other. For convenience, `type_cast` is still a private method on type, so new types that do not need different behavior don't need to implement two methods, but it has been moved to private so it cannot be used accidentally.
* Rename `property` to `attribute`Sean Griffin2014-06-071-3/+3
| | | | For consistency with https://github.com/rails/rails/pull/15557
* Bring type casting behavior of hstore/json in line with serializedSean Griffin2014-06-041-1/+1
| | | | | `@raw_attributes` should not contain the type-cast, mutable version of the value.
* Deprecate decimal columns being automatically treated as integersSean Griffin2014-05-271-0/+4
| | | | | | With ActiveRecord::Properties, we now have a reasonable path for users to continue to keep this behavior if they want it. This is an edge case that has added a lot of complexity to the code base.
* Add missing test case for quoting behaviorSean Griffin2014-05-261-0/+4
| | | | | | | | It appears that the only time that `quote` is called with a column, but without first calling `type_cast` is when where is called with an array. My previous pull request broke this behavior, without failing tests. This adds a test for the only case I can think of that exercises the `if column.type == :integer` branch of `quote` effectively.
* Remove `Column#primary`Sean Griffin2014-05-231-2/+2
| | | | | | | | It appears to have been used at some point in the past, but is no longer used in any meaningful way. Whether a column is considered primary is a property of the model, not the schema/column. This also removes the need for yet another layer of caching of the model's schema, and we can leave that to the schema cache.
* test, inline `DeveloperWithAggregate`, which is used by a single test.Yves Senn2014-05-191-1/+7
|
* Remove dead test code for unsupported adaptersSean Griffin2014-05-171-25/+12
|
* Ensure that the comparison between 'CollectionProxy' and ↵Lauro Caetano2014-04-121-0/+9
| | | | 'AssociationRelation' is consistent.
* Make the comparison between 'Relation' and 'AssociationRelation'Lauro Caetano2014-04-121-0/+9
| | | | consistent.
* The comparison between `Relation` and `CollectionProxy` should be consistent.Lauro Caetano2014-04-111-0/+17
| | | | | | | | | | | Example: author.posts == Post.where(author_id: author.id) # => true Post.where(author_id: author.id) == author.posts # => true Fixes #13506
* Ensure we are returning either `true` or `false` for `#==`Godfrey Chan2014-03-291-6/+7
| | | | | | 460eb83d cused `ActiveRecord::Base#==` to sometimes return `nil` in some cases, this ensures we always return a boolean value. Also fixed a similar problem in AR reflections.
* Test microsecond on mysql 5.6Arthur Neves2014-03-121-1/+1
|
* Ensure #second acts like #first AR finderJason Meller2014-01-201-1/+1
| | | | | | | | | | | | This commit bring the famous ordinal Array instance methods defined in ActiveSupport into ActiveRecord as fully-fledged finders. These finders ensure a default ascending order of the table's primary key, and utilize the OFFSET SQL verb to locate the user's desired record. If an offset is defined in the query, calling #second adds to the offset to get the actual desired record. Fixes #13743.
* set encoding to binmode for pipeAnna Carey2014-01-171-0/+2
|
* reset column information after fiddling with `Encoding.default_internal`Yves Senn2014-01-161-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | This solves order depndent problems in `base_test.rb`. The leaked column information crashed test cases using the `Weird` class later on: ``` 2) Error: BasicsTest#test_group_weirds_by_from: SyntaxError: /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape ... attribute_before_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *arg... ... ^ /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape ...te_before_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *args) ... ^ /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:387: invalid hex escape ...e_type_cast("\x{A4CA}\x{A4DE}\x{A4A8}", *args) ... ^ /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:385:in `module_eval' /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:385:in `define_proxy_call' /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:294:in `block in define_attribute_method' /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:285:in `each' /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:285:in `define_attribute_method' /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:252:in `block in define_attribute_methods' /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:252:in `each' /Users/senny/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:252:in `define_attribute_methods' /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:72:in `block in define_attribute_methods' /Users/senny/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/mutex_m.rb:73:in `synchronize' /Users/senny/.rbenv/versions/2.0.0-p353/lib/ruby/2.0.0/mutex_m.rb:73:in `mu_synchronize' /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:69:in `define_attribute_methods' /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:174:in `method_missing' /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:45:in `public_send' /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:45:in `_assign_attribute' /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:32:in `block in assign_attributes' /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `each' /Users/senny/Projects/rails/activerecord/lib/active_record/attribute_assignment.rb:26:in `assign_attributes' /Users/senny/Projects/rails/activerecord/lib/active_record/core.rb:458:in `init_attributes' /Users/senny/Projects/rails/activerecord/lib/active_record/core.rb:191:in `initialize' /Users/senny/Projects/rails/activerecord/lib/active_record/inheritance.rb:30:in `new' /Users/senny/Projects/rails/activerecord/lib/active_record/inheritance.rb:30:in `new' /Users/senny/Projects/rails/activerecord/lib/active_record/persistence.rb:33:in `create' test/cases/base_test.rb:646:in `test_group_weirds_by_from' ```
* no need to `return skip` in tests. `skip` is enough.Yves Senn2014-01-161-1/+1
|
* Set NameError#nameChulki Lee2014-01-131-1/+3
|
* test case for #limit added - picking latest value from limitAkshay Vishnoi2013-12-171-0/+4
|
* Don't skip tests if we don't need to.Rafael Mendonça França2013-11-081-31/+29
| | | | | | | We can conditional define the tests depending on the adapter or connection. Lets keep the skip for fail tests that need to be fixed.
* Remove private API testRafael Mendonça França2013-11-051-10/+0
|
* Add test verifying that you can only sort ARs of the same typeDavid Heinemeier Hansson2013-11-021-1/+7
|