Defect #30811
closed
"rake db:fixtures:load" does not work
Added by Go MAEDA almost 6 years ago.
Updated over 5 years ago.
Category:
Code cleanup/refactoring
Description
Rails provides a rake task db:fixtures:load
to load fixtures to the database. Fixture data is useful to prepare Redmine for testing. But, in Redmine, the task fails due to test/fixtures/configuration/*.yml
.
$ bin/rake db:fixtures:load
rake aborted!
ActiveRecord::Fixture::FormatError: fixture key is not a hash: /Users/maeda/redmines/redmine-trunk/test/fixtures/configuration/default.yml, keys: ["production", "development", "test"]
This is because db:fixtures:load
assumes that all files which have .yml extension are fixtures. Actually test/fixtures/configuration/*.yml
are not fixtures but files used to test lib/redmine/configuration.rb
.
To run db:fixtures:load
without errors, I suggest changing the extension of those files from .yml to another extension such as .yml.txt.
Files
test/fixtures/configuration/*.yml is test data for Redmine::Configuration but it's not fixtures.
I think that this problem will be solved by changing the location of these files.
(eg. test/fixtures/configuration/*.yml -> test/configuration/*.yml)
Currently, all files used by tests are placed under fixtures
directory. Here are some examples:
- test/fixtures/diffs
- test/fixtures/ldap
- test/fixtures/mail_handler
I think it is better not to move text/fixtures/configuration
outside fixtures
directory because it breaks the implicit rule.
Go MAEDA wrote:
Currently, all files used by tests are placed under fixtures
directory. Here are some examples:
- test/fixtures/diffs
- test/fixtures/ldap
- test/fixtures/mail_handler
I think it is better not to move text/fixtures/configuration
outside fixtures
directory because it breaks the implicit rule.
Thank you for pointing out my problem with my patch.
I was not able to notice the current implicit rules...
Certainly, test data not registered in the DB is also placed in test/fixtures.
As suggested by Go Maeda, I made a patch to change the file name.
- Tracker changed from Feature to Defect
- Subject changed from Change the extension of test/fixtures/configuration/*.yml so that db:fixtures:load does not fail to rake db:fixtures:load does not work
- Target version set to 4.1.0
Maybe ".example" is more appropriate than ".txt"?
Marius BALTEANU wrote:
Maybe ".example" is more appropriate than ".txt"?
Thanks, looks nicer.
- Subject changed from rake db:fixtures:load does not work to "rake db:fixtures:load" does not work
- Status changed from New to Closed
- Assignee set to Go MAEDA
- Resolution set to Fixed
Committed the patch. Thank you for fixing it.
- Target version changed from 4.1.0 to 3.4.11
- Related to Patch #35466: Rename test/fixtures/configuration/*.yml.example to test/fixtures/files/configuration/*.yml added
Also available in: Atom
PDF