Defect #30811

"rake db:fixtures:load" does not work

Added by Go MAEDA about 1 month ago. Updated about 1 month ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Go MAEDA% Done:

0%

Category:Code cleanup/refactoring
Target version:4.1.0
Resolution:Fixed Affected version:

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.

30811.patch Magnifier (1.33 KB) Takenori TAKAKI, 2019-02-18 17:08

rename_configration_fixtures.patch Magnifier (2.18 KB) Takenori TAKAKI, 2019-02-19 06:16

Associated revisions

Revision 17889
Added by Go MAEDA about 1 month ago

"rake db:fixtures:load" does not work (#30811).

Patch by Takenori TAKAKI.

History

#1 Updated by Takenori TAKAKI about 1 month ago

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)

#2 Updated by Go MAEDA about 1 month ago

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.

#3 Updated by Takenori TAKAKI about 1 month ago

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.

#4 Updated by Go MAEDA about 1 month ago

  • 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

#5 Updated by Marius BALTEANU about 1 month ago

Maybe ".example" is more appropriate than ".txt"?

#6 Updated by Go MAEDA about 1 month ago

Marius BALTEANU wrote:

Maybe ".example" is more appropriate than ".txt"?

Thanks, looks nicer.

#7 Updated by Go MAEDA about 1 month ago

  • 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.

Also available in: Atom PDF