aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models
Commit message (Collapse)AuthorAgeFilesLines
* Deprecate :finder_sql, :counter_sql, :insert_sql, :delete_sql.Jon Leighton2012-08-013-26/+36
|
* Revert "Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql."Jon Leighton2012-08-013-1/+24
| | | | | | | | | This reverts commit 3803fcce26b837c0117f7d278b83c366dc4ed370. Conflicts: activerecord/CHANGELOG.md It will be deprecated only in 4.0, and removed properly in 4.1.
* Revert "Removing composed_of from ActiveRecord."Rafael Mendonça França2012-07-272-0/+13
| | | | | | | | | | | This reverts commit 14fc8b34521f8354a17e50cd11fa3f809e423592. Reason: we need to discuss a better path from this removal. Conflicts: activerecord/lib/active_record/reflection.rb activerecord/test/cases/base_test.rb activerecord/test/models/developer.rb
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-276-15/+16
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* rm unnecessary testJon Leighton2012-07-202-5/+0
| | | | | interpolation is no longer a thing separate from "normal" assoc conditions.
* rm redundant testJon Leighton2012-07-201-2/+0
| | | | now everything is converted to the new style, this is not needed
* Remove :finder_sql, :counter_sql, :insert_sql, :delete_sql.Jon Leighton2012-07-203-24/+1
|
* Convert association macros to the new syntaxJon Leighton2012-07-2015-134/+135
|
* Allow associations to take a lambda which builds the scopeJon Leighton2012-07-131-0/+2
|
* Remove some aggregation tests related to composed_ofCarlos Antonio da Silva2012-06-281-1/+0
| | | | | | | | | | | Since composed_of was removed in 051747449e7afc817c599e4135bc629d4de064eb, these tests were working "by mistake", due to the matching "address" string in the error message, but with a different error message than the expected multiparameter assignment error. Since "address" is not an attribute from Customer anymore, the error was "undefined method klass for nil", where nil was supposed to be the column object.
* Merge pull request #6800 from mschneider/dynamic_finders_for_aliased_attributesRafael Mendonça França2012-06-221-0/+2
|\ | | | | Dynamic finders for aliased attributes
| * made dynamic finders alias_attribute awareMaximilian Schneider2012-06-221-0/+2
| | | | | | | | | | previously dynamic finders only worked in combination with the actual column name and not its alias defined with #alias_attribute
* | Add some coverage for AR serialization with serializable_hashCarlos Antonio da Silva2012-06-221-17/+32
| | | | | | | | | | | | ActiveRecord json/xml serialization should use as base serializable_hash, provided by ActiveModel. Add some more coverage around options :only and :except for both json and xml serialization.
* | Improve the derivation of HABTM assocation join table namesAndrew White2012-06-221-0/+5
|/ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Improve the derivation of HABTM join table name to take account of nesting. It now takes the table names of the two models, sorts them lexically and then joins them, stripping any common prefix from the second table name. Some examples: Top level models (Category <=> Product) Old: categories_products New: categories_products Top level models with a global table_name_prefix (Category <=> Product) Old: site_categories_products New: site_categories_products Nested models in a module without a table_name_prefix method (Admin::Category <=> Admin::Product) Old: categories_products New: categories_products Nested models in a module with a table_name_prefix method (Admin::Category <=> Admin::Product) Old: categories_products New: admin_categories_products Nested models in a parent model (Catalog::Category <=> Catalog::Product) Old: categories_products New: catalog_categories_products Nested models in different parent models (Catalog::Category <=> Content::Page) Old: categories_pages New: catalog_categories_content_pages Also as part of this commit the validity checks for HABTM assocations have been moved to ActiveRecord::Reflection One side effect of this is to move when the exceptions are raised from the point of declaration to when the association is built. This is consistant with other association validity checks.
* Removing composed_of from ActiveRecord.Steve Klabnik2012-06-182-12/+0
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This feature adds a lot of complication to ActiveRecord for dubious value. Let's talk about what it does currently: class Customer < ActiveRecord::Base composed_of :balance, :class_name => "Money", :mapping => %w(balance amount) end Instead, you can do something like this: def balance @balance ||= Money.new(value, currency) end def balance=(balance) self[:value] = balance.value self[:currency] = balance.currency @balance = balance end Since that's fairly easy code to write, and doesn't need anything extra from the framework, if you use composed_of today, you'll have to add accessors/mutators like that. Closes #1436 Closes #2084 Closes #3807
* Ensure that mass assignment options are preservedAndrew White2012-06-101-1/+20
| | | | | | | | | | | | | | | | There are two possible scenarios where the @mass_assignment_options instance variable can become corrupted: 1. If the assign_attributes doesn't complete correctly, then subsequent calls to a nested attribute assignment method will use whatever options were passed to the previous assign_attributes call. 2. With nested assign_attributes calls, the inner call will overwrite the current options. This will only affect nested attributes as the attribute hash is sanitized before any methods are called. To fix this we save the current options in a local variable and then restore these options in an ensure block.
* Refactor aggregation writer methodCarlos Antonio da Silva2012-05-211-1/+0
| | | | Only constantize class_name once.
* Merge pull request #6143 from senny/composed_of_converter_returns_nilAaron Patterson2012-05-211-0/+5
|\ | | | | allow the :converter Proc form composed_of to return nil
| * allow the :converter Proc form composed_of to return nilYves Senn2012-05-031-0/+5
| | | | | | | | | | | | | | This makes it possible to filter invalid input values before they are passed into the value-object (like empty strings). This behaviour is only relevant if the :allow_nil options is set to true. Otherwise you will get the resulting NoMethodError.
* | Custom coders support for ActiveRecord::Store. JSON, YAML, Marshal can be ↵Andrey Voronkov2012-05-091-0/+2
| | | | | | | | used out of the box.
* | Fix issue with private kernel methods and collection associations. Closes #2508Carlos Antonio da Silva2012-05-021-0/+5
| | | | | | | | | | | | | | | | Change CollectionProxy#method_missing to use scoped.public_send, to avoid a problem described in issue #2508 when trying to use class methods with names like "open", that clash with private kernel methods. Also changed the dynamic matcher instantiator to send straight to scoped, to avoid another roundtrip to method_missing.
* | find and replace deprecated keysJon Leighton2012-04-271-1/+1
| |
* | %s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other ↵Jon Leighton2012-04-273-8/+8
| | | | | | | | things
* | remove unnecessary test codeJon Leighton2012-04-271-5/+1
| |
* | remove deprecated scope stuffJon Leighton2012-04-263-22/+2
| |
* | remove unused methodJon Leighton2012-04-251-6/+0
| |
* | remove tests for #with_scope (it's now deprecated)Jon Leighton2012-04-251-6/+0
| |
* | extract deprecated codeJon Leighton2012-04-251-2/+2
| |
* | Adds test to check that circular preloading does not modify Model.unscoped ↵Benedikt Deicke2012-04-031-0/+2
| | | | | | | | (as described in #5667)
* | Merge pull request #5334 from courtland/masterJon Leighton2012-03-301-0/+6
|\ \ | | | | | | Fix deleting from a HABTM join table upon destroying an object of a model with optimistic locking enabled.
| * | Tests for removing a HABTM association when optimistic locking is enabled.Nick Rogers2012-03-071-0/+6
| | |
* | | Deprecate eager-evaluated scopes.Jon Leighton2012-03-2116-61/+62
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Don't use this: scope :red, where(color: 'red') default_scope where(color: 'red') Use this: scope :red, -> { where(color: 'red') } default_scope { where(color: 'red') } The former has numerous issues. It is a common newbie gotcha to do the following: scope :recent, where(published_at: Time.now - 2.weeks) Or a more subtle variant: scope :recent, -> { where(published_at: Time.now - 2.weeks) } scope :recent_red, recent.where(color: 'red') Eager scopes are also very complex to implement within Active Record, and there are still bugs. For example, the following does not do what you expect: scope :remove_conditions, except(:where) where(...).remove_conditions # => still has conditions
* | | Not need to pass join attributes to association buildRafael Mendonça França2012-03-072-9/+9
| | |
* | | Add test case to has_many through association when mass_assignment_sanitizer isRafael Mendonça França2012-03-053-0/+13
|/ / | | | | | | :strict
* | added test for #3732Rick Martinez2012-02-103-1/+12
| |
* | Allow store to be a not null column.Jeremy Walker2012-02-021-0/+1
| |
* | test_get_ids_for_ordered_association fixedgregolsen2012-01-311-1/+1
| |
* | ids_reader method fixed, test added to has_many associationgregolsen2012-01-311-0/+1
| |
* | Fix bug where reset_counters resets the wrong counter cache.David Peter2012-01-162-0/+8
| | | | | | | | | | | | | | | | If a model belongs_to two associations with the same class, then reset_counters will reset the wrong counter cache. Finding the right reflection should use the foreign_key instead, which should be unique.
* | Deprecate inferred JOINs with includes + SQL snippets.Jon Leighton2012-01-163-3/+6
| | | | | | | | | | | | See the CHANGELOG for details. Fixes #950.
* | Revert "Deprecate implicit eager loading. Closes #950."Jon Leighton2012-01-163-5/+5
| | | | | | | | This reverts commit c99d507fccca2e9e4d12e49b4387e007c5481ae9.
* | Fixed after_initialize callbacks call on AR model #dupBogdan Gusiev2012-01-071-0/+5
| |
* | Merge branch 'master' of git://github.com/rails/railsDmitry Polushkin2011-12-3128-33/+93
|\ \
| * | Test fixtures with custom model and table namesAlexey Muranov2011-12-302-0/+6
| | | | | | | | | | | | | | | | | | Test using fixtures with random names and model names, that is not following naming conventions but using set_fixture_class instead. It is expected that the table name be defined in the model, but this is not explicitly tested here. This will need to be fixed.
| * | Deprecate implicit eager loading. Closes #950.Jon Leighton2011-12-293-5/+5
| | |
| * | Support establishing connection on ActiveRecord::Model.Jon Leighton2011-12-281-0/+3
| | | | | | | | | | | | | | | This is the 'top level' connection, inherited by any models that include ActiveRecord::Model or inherit from ActiveRecord::Base.
| * | Support nested AR::ModelsJon Leighton2011-12-241-0/+8
| | |
| * | Add test for inheritance from a non-AR superclassJon Leighton2011-12-241-0/+11
| | |
| * | I herd you like modules.Jon Leighton2011-12-241-0/+13
| | |
| * | serialize fails on subclassAlvaro Bautista2011-12-231-0/+4
| | |