aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/test/cases/fixtures_test.rb
Commit message (Collapse)AuthorAgeFilesLines
* Fix crash when loading fixture with belongs_to association defined in ↵Victor Costan2015-06-041-0/+10
| | | | abstract base class.
* Resolve enums in test fixturesGeorge Claghorn2015-05-271-1/+8
| | | | | | | | | | | | | | | | | | | | | | | Currently, values for columns backing Active Record enums must be specified as integers in test fixtures: awdr: title: "Agile Web Development with Rails" status: 2 rfr: title: "Ruby for Rails" status: <%= Book.statuses[:proposed] %> This is potentially confusing, since enum values are typically specified as symbols or strings in application code. To resolve the confusion, this change permits the use of symbols or strings to specify enum values: awdr: status: :published It is compatible with fixtures that specify enum values as integers.
* Rename association option :class to :anonymous_classAndrew White2015-04-211-6/+6
| | | | | | | | | | | | | In 1f006c an option was added called :class to allow passing anonymous classes to association definitions. Since using :class instead of :class_name is a fairly common typo even amongst experienced developers this can result in hard to debug errors arising in raise_on_type_mismatch? To fix this we're renaming the option from :class to :anonymous_class as that is a more correct description of what the option is for. Since this was an internal, undocumented option there is no need for a deprecation. Fixes #19659
* Closes rails/rails#18864: Renaming transactional fixtures to transactional testsBrandon Weiss2015-03-161-10/+10
| | | | | | | | | | | | | | | | | | | | | | | | | I’m renaming all instances of `use_transcational_fixtures` to `use_transactional_tests` and “transactional fixtures” to “transactional tests”. I’m deprecating `use_transactional_fixtures=`. So anyone who is explicitly setting this will get a warning telling them to use `use_transactional_tests=` instead. I’m maintaining backwards compatibility—both forms will work. `use_transactional_tests` will check to see if `use_transactional_fixtures` is set and use that, otherwise it will use itself. But because `use_transactional_tests` is a class attribute (created with `class_attribute`) this requires a little bit of hoop jumping. The writer method that `class_attribute` generates defines a new reader method that return the value being set. Which means we can’t set the default of `true` using `use_transactional_tests=` as was done previously because that won’t take into account anyone using `use_transactional_fixtures`. Instead I defined the reader method manually and it checks `use_transactional_fixtures`. If it was set then it should be used, otherwise it should return the default, which is `true`. If someone uses `use_transactional_tests=` then it will overwrite the backwards-compatible method with whatever they set.
* Merge pull request #19177 from gregmolnar/fixturesRafael Mendonça França2015-03-021-1/+1
|\ | | | | Added testcase for #18742
| * test reset_pk_sequence with multi connectionGreg Molnar2015-03-011-1/+1
| |
* | Merge pull request #17426 from jpcody/fixture_associations_fixAaron Patterson2015-02-241-1/+19
|\ \ | |/ |/| Rely on through table name in has_many fixtures
| * Rely on through table name in has_many fixturesJoshua Cody2014-10-291-1/+19
| | | | | | | | | | | | | | Rather than using the association's join_table method, which constructs a table name from conventions, this should rely on the through reflection's table_name to be resilient to tables that were not automatically named.
* | Fixes #18492Vipul A M2015-01-141-7/+14
| | | | | | | | | | | | | | - Add check for not deleting previously created fixtures, to overcome sti fixtures from multiple files - Added fixtures and fixtures test to verify the same - Fixed wrong fixtures duplicating data insertion in same table
* | Fix lookup of fixtures with non-string labelPrathamesh Sonpatki2015-01-061-0/+4
| | | | | | | | | | | | | | | | | | | | | | - Fixtures with non-string labels such as integers should be accessed using integer label as key. For eg. pirates(1) or pirates(42). - But this results in NotFound error because the label is converted into string before looking up into the fixtures hash. - After this commit, the label is converted into string only if its a symbol. - This issue was fount out while adding a test case for https://github.com/rails/rails/commit/7b910917.
* | make it possible to access fixtures excluded by a `default_scope`.Yves Senn2014-11-211-0/+14
| | | | | | | | | | | | | | | | Prior to this patch you'd end up with an error like: ``` ActiveRecord::RecordNotFound: Couldn't find <Model> with 'id'=<id> [WHERE (<default_scope condition>)] ```
* | Build fix when running in isolationArun Agrawal2014-11-141-0/+1
|/ | | | | `Computer` class needs to be require See #17217 for more details
* speed up fixtures by not loading all their classesgrosser2014-10-061-19/+0
|
* Better regression test for Fixtures with fk as a symbolArthur Neves2014-09-221-10/+1
|
* fix fixtures not loading if a belongs_to association is defined with a ↵Will Bryant2014-09-221-0/+9
| | | | :foreign_key option that's a symbol
* No transaction for a test that creates fixtures in the test bodyAkira Matsuda2014-08-291-0/+1
|
* don't log errors when all is finePeter Schröder2014-07-171-5/+10
|
* remove deprecation call while initializing `ClassCache` objectKuldeep Aggarwal2014-06-111-6/+0
|
* Merge pull request #12016 from roderickvd/uuid_fixesRafael Mendonça França2014-04-041-0/+9
|\ | | | | | | | | | | | | | | | | | | Auto-generate stable fixture UUIDs on PostgreSQL Conflicts: activerecord/CHANGELOG.md activerecord/lib/active_record/fixtures.rb activerecord/test/cases/adapters/postgresql/uuid_test.rb activesupport/CHANGELOG.md
| * Auto-generate stable fixture UUIDs on PostgreSQL.Roderick van Domburg2014-01-071-0/+9
| | | | | | | | Fixes: #11524
* | Revise 'sqlite3:' URL handling for smoother upgradesMatthew Draper2014-04-031-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Restore the 4.0 behaviour for 'sqlite3:///', but deprecate it. We'll change to the absolute-path interpretation in 4.2. The current "correct" spellings for in-memory, relative, and absolute URLs, respectively, are: sqlite3::memory: sqlite3:relative/path sqlite3:/full/path Substantially reverses/defers fbb79b517f3127ba620fedd01849f9628b78d6ce. Uncovered by @guilleiguaran while investigating #14495, though that sounds like a different issue.
* | Extend fixture label replacement to allow string interpolationEric Steele2014-03-151-0/+4
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Allows fixtures to use their $LABEL as part of a string instead of limiting use to the entire value. mark: first_name: $LABEL username: $LABEL1973 email: $LABEL@$LABELmail.com users(:mark).first_name # => mark users(:mark).username # => mark1973 users(:mark).email # => mark@markmail.com
* | Skips linked folder tests if symlink is invalidMikko Johansson2014-02-091-2/+6
|/
* Fix bad test order dependency between LoadAllFixturesTest#test_all_there and ↵Ryan Davis2013-11-161-6/+10
| | | | FoxyFixturesTest#test_ignores_belongs_to_symbols_if_association_and_foreign_key_are_named_the_same
* Just change ENV and restore it afterwards.Federico Ravasio2013-10-071-1/+4
| | | | | | | | | | | Stubbing ENV[] is not safe outside MRI. At some point after the stubbing has occurred a backtrace is printed to the ActiveSupport warning log: there Rubinius accesses ENV['RBX_NOCOLOR'] to determine if it should print the backtrace with colors or not, causing the stub to fail. Other implementations might access ENV in a different way too, we just can't predict it. The only thing we can do here is to actually set the ENV with what we want and restore it afterwards.
* make @bitsweat happy. :heart:Aaron Patterson2013-09-091-0/+6
|
* stop using deprecated api in the testsAaron Patterson2013-09-091-1/+1
|
* Fix fixtures regression that required table names to map to classes only, ↵Jeremy Kemper2013-09-081-1/+1
| | | | not class names
* auto link hm:t fixture join tables like habtmAaron Patterson2013-09-061-0/+35
|
* Add config to method calls in fixtures.wangjohn2013-08-261-1/+1
| | | | | | | Allows you to change your configuration for calls to `table_name_prefix`, `table_name_suffix`, and `pluralize_table_names`. The default configuration is still ActiveRecord::Base, but you are now able to change the configuration easily.
* Removing instances of string class_names in fixtures.wangjohn2013-08-241-7/+7
| | | | | | | Also, constantizing the default_fixture_model_name when it gets loaded in from the file. Later, when the class_name is passed to a new FixtureSet, a deprecation warning will occur if the class_name is a string.
* load fixtures from linked foldersKassio Borges2013-08-051-2/+2
|
* remove deprecated `ActiveRecord::Base#connection` method.Yves Senn2013-07-011-4/+0
|
* fixture setup does not rely on `AR::Base.configurations`.Yves Senn2013-06-151-0/+16
| | | | | | | | As you can also configure your database connection using `ENV["DATABASE_URL"]`, the fixture setup can't reply on the `.configurations` Hash. As the fixtures are only loaded when ActiveRecord is actually used (`rails/test_help.rb`) it should be safe to drop the check for an existing configuration.
* Allows setting fixture_path to a PathnameAlexander Murmann and Can Berk Güder2013-03-211-0/+9
|
* Deprecate #connection in favour of accessing it via the classBen Moss2013-03-091-3/+2
| | | | | This allows end-users to have a `connection` method on their models without clashing with ActiveRecord internals.
* Revert "Merge pull request #8989 from robertomiranda/use-rails-4-find-by"Guillermo Iguaran2013-01-181-3/+3
| | | | | This reverts commit 637a7d9d357a0f3f725b0548282ca8c5e7d4af4a, reversing changes made to 5937bd02dee112646469848d7fe8a8bfcef5b4c1.
* User Rails 4 find_byrobertomiranda2013-01-181-3/+3
|
* Rename "Fixtures" class to "FixtureSet"Alexey Muranov2012-10-071-23/+23
| | | | 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.
* remove calls to find(:first), find(:last) and find(:all)Jon Leighton2012-04-261-1/+1
|
* properly namespace the fixture exceptionAaron Patterson2012-03-221-1/+1
|
* Revert PR#5001 "removed unuseful require for reply as we are not using ↵Vishnu Atrai2012-02-121-0/+1
| | | | | | require model" This reverts commit 7381596ea32aff47222af89e4bc66000f4597acb.
* removed unuseful require for reply as we are not using require modelKarunakar (Ruby)2012-02-111-1/+0
|
* fix fixtures test as table_name is a string nowSergey Nartimov2012-01-261-2/+2
|
* create_fixtures should accept symbol keys for custom table -> class ↵Jeremy Kemper2012-01-031-2/+10
| | | | mappings. Fixes an unintended regression.
* setup_fixture_accessors should accept symbols for table names. Fixes an ↵Jeremy Kemper2012-01-031-1/+1
| | | | unintended (and untested) regression.
* Test case: fixture table name is defined in modelAlexey Muranov2011-12-301-0/+5
|
* Test fixtures with custom model and table namesAlexey Muranov2011-12-301-0/+28
| | | | | | 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-23/+37
| | | | 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.
* remove checks for encodings availabilitySergey Nartimov2011-12-251-1/+1
|