aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/fixtures
Commit message (Collapse)AuthorAgeFilesLines
* Fix broken link to Fixtures documentation on guidesDavid Padilla2013-08-291-1/+1
| | | | | | and activerecord tests [ci skip]
* load fixtures from linked foldersKassio Borges2013-08-053-0/+13
|
* has_many through obeys order on through associationNeeraj Singh2013-04-042-0/+11
| | | | fixes #10016
* Merge pull request #9141 from adamgamble/issue-9091David Heinemeier Hansson2013-04-031-0/+4
|\ | | | | belongs_to :touch should touch old record when transitioning.
| * + Add test for auto timestamps update of both old & new parent recordsPikachuEXE2013-03-141-0/+4
| |
* | Update other counter caches on destroyIan Young2013-03-202-0/+4
| |
* | Refactor Person/Friendship relationships to be more intuitiveMack Earnhardt2013-03-172-2/+5
|/ | | | | | | | PR #5210 added a Friendship model to illustrate a bug, but in doing so created a confusing structure because both belongs_to declarations in Friendship referred to the same side of the join. The new structure maintains the integrity of the bug test while changing the follower relationship to be more useful for other testing.
* test case for `serialize` default values.Yves Senn2013-03-071-0/+4
| | | | Closes #9110
* Prevent Relation#merge from collapsing wheres on the RHSJon Leighton2013-01-271-1/+3
| | | | | | | | | | | | | | | | | | | | | | | This caused a bug with the new associations implementation, because now association conditions are represented as Arel nodes internally right up to when the whole thing gets turned to SQL. In Rails 3.2, association conditions get turned to raw SQL early on, which prevents Relation#merge from interfering. The current implementation was buggy when a default_scope existed on the target model, since we would basically end up doing: default_scope.merge(association_scope) If default_scope contained a where(foo: 'a') and association_scope contained a where(foo: 'b').where(foo: 'c') then the merger would see that the same column is representated on both sides of the merge and collapse the wheres to all but the last: where(foo: 'c') Now, the RHS of the merge is left alone. Fixes #8990
* Rename "Fixtures" class to "FixtureSet"Alexey Muranov2012-10-073-8/+8
| | | | Rename `ActiveRecord::Fixtures` class to `ActiveRecord::FixtureSet`. Instances of this class normally hold a collection of fixtures (records) loaded either from a single YAML file, or from a file and a folder with the same name. This change make the class name singular and makes the class easier to distinguish from the modules like `ActiveRecord::TestFixtures`, which operates on multiple fixture sets, or `DelegatingFixtures`, `::Fixtures`, etc., and from the class `ActiveRecord::Fixture`, which corresponds to a single fixture.
* test cleanup, remove ruby_type because it's no longer neededYves Senn2012-09-031-6/+0
| | | | | 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-1/+12
| | | | | | 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-0/+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'
* reset_counters() was crashing when there were multiple belongs_to ↵Dave Desrochers2012-08-212-0/+7
| | | | | | associations with the same foreign key. This closes #5200.
* Fix occasional microsecond conversion inaccuracyAri Pollak2012-08-151-1/+1
| | | | | | | | | ActiveRecord::ConnectionAdapters::Column#microseconds did an unnecessary conversion to from Rational to float when calculating the integer number of microseconds. Some terminating decimal numbers in base10 are repeating decimal numbers in base2 (the format of float), and occasionally this causes a rounding error. Patch & explanation originally from Logan Bowers.
* Improve the derivation of HABTM assocation join table namesAndrew White2012-06-221-3/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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.
* Fix backward compatibility with stored Hash values. Wrap coders to convert ↵Jeremy Kemper2012-05-301-0/+3
| | | | serialized values to indifferent access.
* Tests for removing a HABTM association when optimistic locking is enabled.Nick Rogers2012-03-071-0/+3
|
* added test for #3732Rick Martinez2012-02-102-0/+4
|
* Replaced all 'for' loops with Enumerable#eachNathan Broadbent2012-01-301-1/+1
|
* Fix bug where reset_counters resets the wrong counter cache.David Peter2012-01-162-0/+7
| | | | | | | | 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.
* Test fixtures with custom model and table namesAlexey Muranov2011-12-303-0/+21
| | | | | | 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.
* Fix a fixtures test case with table prefix/suffixAlexey Muranov2011-12-271-0/+42
| | | | Make sure the table name of a model is reset in a test case after assigning ActiveRecord::Base.table_name_prefix and ActiveRecord::Base.table_name_suffix.
* Fixtures support for ActiveRecord::ModelJon Leighton2011-12-241-0/+3
|
* Revert "Merge pull request #4114 from ↵Jon Leighton2011-12-221-42/+0
| | | | | | | | | alexeymuranov/my_fix_for_prefix_suffix_fixtures_test" This reverts commit f8e484d0f71114675ed04e987914d3f2815cb868, reversing changes made to fa5adfb1e884bf21a7071ade634a820e37ac4db4. Reason: broke the postgres tests.
* Fix a fixtures test case with table prefix/suffixAlexey Muranov2011-12-221-0/+42
| | | Make sure the table name of a model is reset in a test case after assigning ActiveRecord::Base.table_name_prefix and ActiveRecord::Base.table_name_suffix. This was somebody else's test case, so an independent opinion on the change can be helpful.
* restores the API docs of AR::Fixtures, made a quick pass over them, revises ↵Xavier Noria2011-09-031-1/+1
| | | | link in fixture template [closes #2840]
* Quote these dates to prevent intermittent test failure. Suppose local time ↵Jon Leighton2011-08-041-2/+2
| | | | is 00:50 GMT+1. Without the quoting, the YAML parser would parse this as 00:50 UTC, into the local time of 01:50 GMT+1. Then, it would get written into the database in local time as 01:50. When it came back out the UTC date from the database and the UTC date of two weeks ago would be compared. The former would be 23:50, and the latter would be 00:50, so the two dates would differ, causing the assertion to fail. Quoting it prevents the YAML parser from getting involved.
* Revert "this fixes a brittle test in fixtures_test.rb which fails when you ↵Aaron Patterson2011-07-201-2/+2
| | | | | | are in a timezone which is ahead of UTC but UTC is in the previous day still." This reverts commit f92cefa95f44bcd550c402a7f5ba914f3bd783cc.
* this fixes a brittle test in fixtures_test.rb which fails when you are in a ↵Josh Kalderimis2011-07-201-2/+2
| | | | timezone which is ahead of UTC but UTC is in the previous day still.
* Revert "Fix failure in test_preserves_existing_fixture_data from ↵Jon Leighton2011-07-171-2/+2
| | | | | | test/cases/fixtures_test.rb when UTC and local time occur on different dates." I am pretty sure this was an incorrect fix, and it still failed in certain circumstances anyway. I am now unable to reproduce the original failure I was experiencing so will leave it for now and see if this pops up again. This reverts commit e4479b2f1bc54edf155408d51dd3236955150ce1.
* Fix failure in test_preserves_existing_fixture_data from ↵Jon Leighton2011-07-121-2/+2
| | | | test/cases/fixtures_test.rb when UTC and local time occur on different dates.
* properly reference yml alias nodesdmathieu2011-05-241-1/+1
| | | | as per the last version of the yml specifications : http://www.yaml.org/spec/1.2/spec.html#* alias//
* fixing 1.8 support for new fixture testsAaron Patterson2011-05-231-1/+1
|
* Don't use select() values from the join model of a through association. ↵Jon Leighton2011-05-111-0/+7
| | | | Fixes #508.
* deprecating CSV fixture supportAaron Patterson2011-05-101-0/+0
|
* Don't quote ID's as Arel will quote them -- follow same conventions as the ↵Christopher Meiklejohn2011-05-081-0/+7
| | | | delete method.
* Namespace Fixtures in ActiveRecordJason Noble2011-05-072-6/+6
| | | [Fixes #439]
* Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-101-1/+1
|\
| * revises links to the API websites of individual components (no longer ↵Xavier Noria2011-03-091-1/+1
| | | | | | | | maintained), and rewrites the section about after and around filters in the controller guide
* | Add a test for STI on the through where the through is nested, and change ↵Jon Leighton2011-03-051-0/+10
| | | | | | | | the code which support this
* | Merge branch 'master' into nested_has_many_throughJon Leighton2011-03-047-2/+23
|\| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/CHANGELOG activerecord/lib/active_record/association_preload.rb activerecord/lib/active_record/associations.rb activerecord/lib/active_record/associations/class_methods/join_dependency.rb activerecord/lib/active_record/associations/class_methods/join_dependency/join_association.rb activerecord/lib/active_record/associations/has_many_association.rb activerecord/lib/active_record/associations/has_many_through_association.rb activerecord/lib/active_record/associations/has_one_association.rb activerecord/lib/active_record/associations/has_one_through_association.rb activerecord/lib/active_record/associations/through_association_scope.rb activerecord/lib/active_record/reflection.rb activerecord/test/cases/associations/has_many_through_associations_test.rb activerecord/test/cases/associations/has_one_through_associations_test.rb activerecord/test/cases/reflection_test.rb activerecord/test/cases/relations_test.rb activerecord/test/fixtures/memberships.yml activerecord/test/models/categorization.rb activerecord/test/models/category.rb activerecord/test/models/member.rb activerecord/test/models/reference.rb activerecord/test/models/tagging.rb
| * Merge remote branch 'rails/master' into identity_mapEmilio Tagua2011-02-159-8/+30
| |\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Conflicts: activerecord/examples/performance.rb activerecord/lib/active_record/association_preload.rb activerecord/lib/active_record/associations.rb activerecord/lib/active_record/associations/association_proxy.rb activerecord/lib/active_record/autosave_association.rb activerecord/lib/active_record/base.rb activerecord/lib/active_record/nested_attributes.rb activerecord/test/cases/relations_test.rb
| | * Correctly update counter caches on deletion for has_many :through [#2824 ↵Jon Leighton2011-02-071-0/+2
| | | | | | | | | | | | state:resolved]. Also fixed a bunch of other counter cache bugs in the process, as once I fixed this one others started appearing like nobody's business.
| | * has_one should always remove the old record (properly), even if not saving ↵Jon Leighton2011-01-111-0/+1
| | | | | | | | | | | | the new record, so we don't get the database into a pickle
| | * Make serialized fixtures work againPratik Naik2010-12-291-0/+6
| | |
| | * Associations: DRY up the code which is generating conditions, and make it ↵Jon Leighton2010-12-261-1/+0
| | | | | | | | | | | | all use arel rather than SQL strings
| | * Fix dodgy tests which were effectively asserting nil == nilJon Leighton2010-12-261-0/+1
| | |
| | * using arel to compile sql statementsAaron Patterson2010-12-251-0/+1
| | |
| | * If a has_many goes :through a belongs_to, and the foreign key of the ↵Jon Leighton2010-12-235-8/+20
| | | | | | | | | | | | belongs_to changes, then the has_many should be considered stale.