aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/models/developer.rb
Commit message (Collapse)AuthorAgeFilesLines
* 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
|
* Raise error when has_many through is defined before through associationChris Holmes2017-01-041-0/+6
| | | | | | | https://github.com/rails/rails/issues/26834 This change raises an error if a has_many through association is defined before the through association.
* Replace sleep with synchronizationMatthew Draper2017-01-021-1/+1
|
* applies remaining conventions across the projectXavier Noria2016-08-061-1/+0
|
* modernizes hash syntax in activerecordXavier Noria2016-08-061-43/+43
|
* applies new string literal convention in activerecord/testXavier Noria2016-08-061-51/+51
| | | | | The current code base is not uniform. After some discussion, we have chosen to go with double quotes by default.
* Fix merge conflicts for #19938Sean Griffin2015-10-201-0/+2
|\ | | | | | | | | This is a separate commit, as it is not just a changelog conflict. Want to point out the changes in the code
| * Fix for activerecord join dependency instantiate bugMehmet Emin İNAÇ2015-05-041-0/+2
| | | | | | | | | | | | | | | | | | | | | | | | use only object_id instead parent class and parent id test cases assert_equal use table name in references fix minor problems
* | Fix regression in inverse_of on through associationseileencodes2015-09-261-0/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | `inverse_of` on through associations was accidently removed/caused to stop working in commit f8d2899 which was part of a refactoring on `ThroughReflection`. To fix we moved `inverse_of` and `check_validity_of_inverse!` to the `AbstractReflection` so it's available to the `ThroughReflection` without having to dup any methods. We then need to delegate `inverse_name` method in `ThroughReflection`. `inverse_name` can't be moved to `AbstractReflection` without moving methods that set the instance variable `@automatic_inverse_of`. This adds a test that ensures that `inverse_of` on a `ThroughReflection` returns the correct class name, and the correct record for the inverse relationship. Fixes #21692
* | Implement ActiveRecord::Base.ignored_columnsJean Boussier2015-09-241-0/+5
| |
* | Only nullify persisted has_one target associationsAgis-2015-08-241-0/+1
|/ | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Ensure HABTM relationships produce valid class names (Fixes #17119)Sammy Larbi2014-11-091-0/+2
|
* Only merge scopes with zero arity in has_many throughAgis-2014-08-201-0/+2
| | | | | | | | | | | | | | | with dynamic conditions. Fixes #16128 This bug was introduced in https://github.com/rails/rails/commit/c35e438620f2d56562251571377995359546393d so it's present from 4.1.2-rc1 and after. https://github.com/rails/rails/commit/c35e438620f2d56562251571377995359546393d merges any relation scopes passed as proc objects to the relation, but does *not* take into account the arity of the lambda. To reproduce: https://gist.github.com/Agis-/5f1f0d664d2cd08dfb9b
* test, inline `DeveloperWithAggregate`, which is used by a single test.Yves Senn2014-05-191-6/+0
|
* Fixed HABTM's CollectionAssociation sizeFred Wu2014-05-081-0/+2
| | | | | HABTM should fall back to using the normal CollectionAssociation's size calculation if the collection is not cached or loaded. This addresses both #14913 and #14914 for master.
* Add tests for default scope behaviour changeJon Leighton2014-02-231-0/+2
| | | | See #13875
* make sure cached table name is a string. fixes #12582Aaron Patterson2013-12-121-0/+4
|
* adding a test to demonstrate how to use STI subclasses on the far rightAaron Patterson2013-09-271-0/+2
| | | | side of a hm:t association along with preloading.
* this code is dead, removingAaron Patterson2013-08-011-6/+0
|
* Fix .update_all and .delete_all when using a condition on a joined tableDerek Kraan2013-01-111-0/+9
| | | | | | | | | in a default_scope. `Model.joins(...).where(condition_on_joined_table).update_all` / `delete_all` worked, but the same operation implemented with a default_scope generated a SQL error because ActiveRecord ignored the join but implemented the where condition anyways.
* Allow users to choose the timestamp format in the cache keyRafael Mendonça França2012-12-101-0/+5
| | | | | | | This can be done using the class attribute cache_timestamp_format Conflicts: railties/guides/source/configuring.textile
* Do not instantiate intermediate AR objects when eager loading.Yves Senn2012-12-041-0/+10
| | | | Closes #3313
* Revert "Removing composed_of from ActiveRecord."Rafael Mendonça França2012-07-271-0/+6
| | | | | | | | | | | 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-271-4/+4
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* Convert association macros to the new syntaxJon Leighton2012-07-201-11/+11
|
* 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.
* Removing composed_of from ActiveRecord.Steve Klabnik2012-06-181-5/+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
* %s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other ↵Jon Leighton2012-04-271-4/+4
| | | | things
* remove unused methodJon Leighton2012-04-251-6/+0
|
* remove tests for #with_scope (it's now deprecated)Jon Leighton2012-04-251-6/+0
|
* Deprecate eager-evaluated scopes.Jon Leighton2012-03-211-16/+16
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Fix default scope thread safety. Thanks @thedarkone for reporting.Jon Leighton2011-08-131-0/+9
|
* Apply the default scope earlier when doing calculations. Fixes #1682.Jon Leighton2011-06-231-0/+6
|
* Failing test for aggregating on default_scope with selectErik Fonselius2011-05-311-0/+5
|
* Fix infinite recursion where a lazy default scope references a scope. Fixes ↵Jon Leighton2011-05-251-0/+15
| | | | #1264.
* Failing tests for #1233.Andrew White2011-05-241-0/+35
|
* removed the default_scope deprecations and updated the docs and tests to ↵Josh Kalderimis2011-04-281-6/+18
| | | | reflect its use cases
* Bring back support for passing a callable object to the default_scope macro. ↵Jon Leighton2011-04-181-0/+17
| | | | You can also just use a block.
* Un-deprecate using 'default_scope' as a macro, but if you are calling the ↵Jon Leighton2011-04-181-52/+16
| | | | macro multiple times that will give deprecation warnings, and in 3.2 we will simply overwrite the default scope when you call the macro multiple times.
* Evaluate default scopes at the last possible moment in order to avoid ↵Jon Leighton2011-04-121-0/+2
| | | | problems with default scopes getting included into other scopes and then being unable to remove the default part via unscoped.
* Deprecated support for passing hashes and relations to default_scope, in ↵Jon Leighton2011-04-121-4/+65
| | | | favour of defining a 'default_scope' class method in the model. See the CHANGELOG for more details.
* reorder removed in favor of except(:order).orderSantiago Pastorino2010-10-111-1/+0
|
* failing test for reorder overriding default_scopeNick Ragaz2010-09-051-1/+1
| | | | | | [5528] Signed-off-by: Santiago Pastorino <santiago@wyeworks.com>
* Change relation merging to always append select, group and order valuesPratik Naik2010-08-311-1/+1
|
* Deletes trailing whitespaces (over text files only find * -type f -exec sed ↵Santiago Pastorino2010-08-141-1/+1
| | | | 's/[ \t]*$//' -i {} \;)
* Added reorder delegation for ActiveRecord::Base(to be able to overwrite the ↵Vitalii Khustochka2010-07-131-0/+1
| | | | | | default_scope ordering in the named scope [#5093 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* with_exclusive_scope does not work properly if ARel is passed. It does work ↵Neeraj Singh2010-06-291-1/+7
| | | | | | | | nicely if hash is passed. Blow up if user is attempting it pass ARel to with_exclusive_scope. [#3838 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Fix a bug where default_scope was overriding attributes given on model ↵Henry Hsu2010-02-261-0/+5
| | | | | | initialization [#3218 status:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>