プロジェクト

全般

プロフィール

Vote #79837

完了

"rake db:fixtures:load" does not work

Admin Redmine さんが4年以上前に追加. 4年以上前に更新.

ステータス:
Closed
優先度:
通常
担当者:
-
カテゴリ:
Code cleanup/refactoring_30
対象バージョン:
開始日:
2022/05/09
期日:
進捗率:

0%

予定工数:
category_id:
30
version_id:
150
issue_org_id:
30811
author_id:
332
assigned_to_id:
332
comments:
9
status_id:
5
tracker_id:
1
plus1:
0
affected_version:
closed_on:
affected_version_id:
ステータス-->[Closed]

説明

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.


journals

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.

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------
Maybe ".example" is more appropriate than ".txt"?
--------------------------------------------------------------------------------
Marius BALTEANU wrote:
> Maybe ".example" is more appropriate than ".txt"?

Thanks, looks nicer.
--------------------------------------------------------------------------------
Committed the patch. Thank you for fixing it.
--------------------------------------------------------------------------------

--------------------------------------------------------------------------------

--------------------------------------------------------------------------------


related_issues

relates,Closed,35466,Rename test/fixtures/configuration/*.yml.example to test/fixtures/files/configuration/*.yml

他の形式にエクスポート: Atom PDF

いいね!0
いいね!0