Project

General

Profile

Actions

Defect #30811

closed

"rake db:fixtures:load" does not work

Added by Go MAEDA over 5 years ago. Updated about 5 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Code cleanup/refactoring
Target version:
Start date:
Due date:
% Done:

0%

Estimated time:
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.


Files

30811.patch (1.33 KB) 30811.patch Takenori TAKAKI, 2019-02-18 17:08
rename_configration_fixtures.patch (2.18 KB) rename_configration_fixtures.patch Takenori TAKAKI, 2019-02-19 06:16

Related issues

Related to Redmine - Patch #35466: Rename test/fixtures/configuration/*.yml.example to test/fixtures/files/configuration/*.ymlClosedGo MAEDA

Actions
Actions #1

Updated by Takenori TAKAKI over 5 years 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)

Actions #2

Updated by Go MAEDA over 5 years 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.

Actions #3

Updated by Takenori TAKAKI over 5 years 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.

Actions #4

Updated by Go MAEDA over 5 years 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
Actions #5

Updated by Marius BÄ‚LTEANU over 5 years ago

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

Actions #6

Updated by Go MAEDA over 5 years ago

Marius BALTEANU wrote:

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

Thanks, looks nicer.

Actions #7

Updated by Go MAEDA over 5 years 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.

Actions #8

Updated by Go MAEDA about 5 years ago

  • Target version changed from 4.1.0 to 3.4.11
Actions #9

Updated by Go MAEDA almost 3 years ago

  • Related to Patch #35466: Rename test/fixtures/configuration/*.yml.example to test/fixtures/files/configuration/*.yml added
Actions

Also available in: Atom PDF