aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/inheritance_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* User assert_kind_of, invert assert_equal expectationsCarlos Antonio da Silva2012-11-291-3/+3
|
* Added STI support to init and building associationsJason Rush2012-11-291-0/+23
| | | | | | | | Allows you to do BaseClass.new(:type => "SubClass") as well as parent.children.build(:type => "SubClass") or parent.build_child to initialize an STI subclass. Ensures that the class name is a valid class and that it is in the ancestors of the super class that the association is expecting.
* Remove ActiveRecord::ModelJon Leighton2012-10-261-10/+1
| | | | | | | | | | In the end I think the pain of implementing this seamlessly was not worth the gain provided. The intention was that it would allow plain ruby objects that might not live in your main application to be subclassed and have persistence mixed in. But I've decided that the benefit of doing that is not worth the amount of complexity that the implementation introduced.
* test cleanup, remove ruby_type because it's no longer neededYves Senn2012-09-031-1/+1
| | | | | All tests with a custom inheritance_column use the `Vegtable` model. The field ruby_type on the Company models is no longer needed
* rewrite inheritance tests with a custom inheritance_columnYves Senn2012-09-031-48/+38
| | | | | | previously the tests with and without a custom `inheritance_column` used the same models. Since the model then has both fields this can lead to false positives.
* set the configured #inheritance_column on #become (#7503)Yves Senn2012-09-031-1/+9
| | | | | | | | | | | | | | | I had to create a new table because I needed an STI table, which does not have both a "type" and a "custom_type" the test fails with: 1) Error: test_alt_becomes_works_with_sti(InheritanceTest): NoMethodError: undefined method `type=' for #<Cabbage id: 1, name: "my cucumber", custom_type: "Cucumber"> /Users/username/Projects/rails/activemodel/lib/active_model/attribute_methods.rb:432:in `method_missing' /Users/username/Projects/rails/activerecord/lib/active_record/attribute_methods.rb:100:in `method_missing' /Users/username/Projects/rails/activerecord/lib/active_record/persistence.rb:165:in `becomes' test/cases/inheritance_test.rb:134:in `test_becomes_works_with_sti' test/cases/inheritance_test.rb:140:in `test_alt_becomes_works_with_sti'
* Remove ActiveRecord::Base.to_aJon Leighton2012-08-031-2/+2
| | | | | On reflection, it seems like a bit of a weird method to have on ActiveRecord::Base, and it shouldn't be needed most of the time anyway.
* Deprecate ActiveRecord::Base.scoped.Jon Leighton2012-07-271-12/+12
| | | | | | | It doesn't serve much purpose now that ActiveRecord::Base.all returns a Relation. The code is moved to active_record_deprecated_finders.
* ActiveRecord::Base.all returns a Relation.Jon Leighton2012-07-271-6/+6
| | | | | | | | | | | Previously it returned an Array. If you want an array, call e.g. `Post.to_a` rather than `Post.all`. This is more explicit. In most cases this should not break existing code, since Relations use method_missing to delegate unknown methods to #to_a anyway.
* Refactor ActiveRecord::Inheritance.base_class logicbeerlington2012-07-261-0/+30
| | | | | | | | | Moved logic from class_of_active_record_descendant(class) to the base_class method. This method was confusing because it required an argument, but that argument was 'self'. Moved base_class tests to inheritance_test.rb and added some test coverage for some untested cases.
* remove deprecated callsJon Leighton2012-04-271-2/+2
|
* find and replace deprecated keysJon Leighton2012-04-271-7/+7
|
* %s/find(:\(first\|last\|all\), \([^()]*\))/scoped(\2).\1/gcI amongst other ↵Jon Leighton2012-04-271-10/+10
| | | | things
* remove calls to find(:first), find(:last) and find(:all)Jon Leighton2012-04-261-4/+4
|
* Support establishing connection on ActiveRecord::Model.Jon Leighton2011-12-281-1/+0
| | | | | This is the 'top level' connection, inherited by any models that include ActiveRecord::Model or inherit from ActiveRecord::Base.
* Deprecate set_inheritance_column in favour of self.inheritance_column=Jon Leighton2011-11-291-2/+2
|
* please use ruby -I lib:test path/to/test.rb, or export RUBY_OPTAaron Patterson2011-06-061-1/+1
|
* Refactor Active Record test connection setup. Please see the ↵Jon Leighton2011-06-041-1/+1
| | | | RUNNING_UNIT_TESTS file for details, but essentially you can now configure things in test/config.yml. You can also run tests directly via the command line, e.g. ruby path/to/test.rb (no rake needed, uses default db connection from test/config.yml). This will help us fix the CI by enabling us to isolate the different Rails versions to different databases.
* Rewrote AssociationPreload.Jon Leighton2011-02-281-1/+1
|
* just use a hash for doing association cachingAaron Patterson2011-01-071-1/+1
|
* take more advantage of arel sql compilerAaron Patterson2010-12-251-1/+1
|
* stop redifining methods on every call to set_primary_keyAaron Patterson2010-12-241-0/+4
|
* fixing dup regressionsAaron Patterson2010-11-231-1/+1
|
* type_name should check for blank because people may have messed up databasesAaron Patterson2010-09-301-0/+14
|
* Add scoping and unscoped as the syntax to replace the old with_scope and ↵José Valim2010-06-291-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | with_exclusive_scope. A few examples: * with_scope now should be scoping: Before: Comment.with_scope(:find => { :conditions => { :post_id => 1 } }) do Comment.first #=> SELECT * FROM comments WHERE post_id = 1 end After: Comment.where(:post_id => 1).scoping do Comment.first #=> SELECT * FROM comments WHERE post_id = 1 end * with_exclusive_scope now should be unscoped: class Post < ActiveRecord::Base default_scope :published => true end Post.all #=> SELECT * FROM posts WHERE published = true Before: Post.with_exclusive_scope do Post.all #=> SELECT * FROM posts end After: Post.unscoped do Post.all #=> SELECT * FROM posts end Notice you can also use unscoped without a block and it will return an anonymous scope with default_scope values: Post.unscoped.all #=> SELECT * FROM posts
* Final iteration of use better testing methodsNeeraj Singh2010-05-191-7/+7
| | | | | | [#4652 state:resolved] Signed-off-by: José Valim <jose.valim@gmail.com>
* Changed ActiveRecord::Base.store_full_sti_class to be true by default ↵David Heinemeier Hansson2010-01-031-0/+3
| | | | reflecting the previously announced Rails 3 default [DHH]
* Merge commit 'rails/master'Emilio Tagua2009-08-081-1/+2
|\ | | | | | | | | | | Conflicts: activerecord/test/cases/adapter_test.rb activerecord/test/cases/method_scoping_test.rb
| * added :order to find :all as otherwise Oracle tests were failingRaimonds Simanovskis2009-08-061-1/+2
| |
* | Merge commit 'rails/master'Emilio Tagua2009-06-301-2/+2
|\|
| * Revert "Revert "Generate proper :counter_sql from :finder_sql when there is ↵Pratik Naik2009-07-011-2/+2
| | | | | | | | | | | | | | | | | | a newline character immediately following 'SELECT' [#2118 state:resolved]"" This reverts commit 80f1f863cd0f9cba89079511282de5710a2e1832. The feature doesn't work on Postgres, so don't test it on Postgres. Also, Postgres compatibility is irrelevant to the ticket/patch in question.
| * Revert "Generate proper :counter_sql from :finder_sql when there is a ↵Yehuda Katz + Carl Lerche2009-06-221-2/+2
| | | | | | | | | | | | | | | | newline character immediately following 'SELECT' [#2118 state:resolved]" This reverts commit 4851ca9e13a4317342df02ae25b1929340523f7a. The tests do not pass for postgresql.
| * Generate proper :counter_sql from :finder_sql when there is a newline ↵Patrick Joyce2009-06-211-2/+2
| | | | | | | | | | | | character immediately following 'SELECT' [#2118 state:resolved] Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* | Calculations now use Arel to construct the query.Emilio Tagua2009-04-291-2/+2
|/ | | | Implemented other methods in AR::Base with Arel support.
* Ruby 1.9 compat: rename deprecated assert_raises to assert_raise.Jeremy Kemper2009-03-081-2/+2
| | | | [#1617 state:resolved]
* Remove SQL Server cases from tests for latest adapter work to pass rails ↵Ken Collins2008-11-191-2/+2
| | | | | | expected behavior. Signed-off-by: Michael Koziarski <michael@koziarski.com>
* fixed association preloading to use = instead of IN when there's only one recordrsl2008-09-101-1/+1
| | | | | | [#1013 state:committed] Signed-off-by: Jeremy Kemper <jeremy@bitsweat.net>
* Fix file permissionsTarmo Tänav2008-07-311-0/+0
| | | | Signed-off-by: Joshua Peek <josh@joshpeek.com>
* Fix integer quoting issues in association preload. [#602 state:resolved]Tiago Macedo2008-07-141-0/+7
| | | | Signed-off-by: Pratik Naik <pratiknaik@gmail.com>
* Namespace Inflector, Dependencies, OrderedOptions, and TimeZone under ↵Joshua Peek2008-06-031-2/+2
| | | | ActiveSupport [#238 state:resolved]
* Add ActiveRecord::Base.sti_name that checks ↵rick2008-05-311-1/+17
| | | | ActiveRecord::Base#store_full_sti_class? and returns either the full or demodulized name. [rick] [#114 state:resolved]
* Add ActiveRecord option to store the full class name on STI's type column, ↵Rodrigo Kochenburger2008-05-131-0/+28
| | | | | | allowing one to have STI subclasses in different namespaces [#114] Signed-off-by: rick <technoweenie@gmail.com>
* Merge branch 'ar-test-cleanup' of git://git.geeksomnia.com/railsJeremy Kemper2008-01-211-3/+3
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8681 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Fix pathsJeremy Kemper2008-01-181-3/+3
| | | | git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8661 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
* Move tests to casesJeremy Kemper2008-01-181-0/+211
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8660 5ecf4fe2-1ee6-0310-87b1-e25e094e27de