開発環境において休会中ユーザーのプロフィールに休会情報が表示されないバグを修正#9712
Conversation
📝 WalkthroughWalkthroughdb/fixtures/hibernations.yml に hibernation3〜hibernation9 の7件のハイバネーションフィクスチャを追加。各エントリはユーザー、scheduled_return_on(Time.current + 30.days)、reason、created_at(Time.current に対するオフセット)を含む。既存エントリは変更していない。 Changes
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~3 minutes Possibly related issues
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Tip Try Coding Plans. Let us write the prompt for your AI agent so you can ship faster (with fewer bugs). Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
36134c8 to
d8427ad
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
db/fixtures/hibernations.yml (1)
31-31:.hourを.hoursに統一してください。プロジェクト方針として、時間の加算には
Numeric#hours(複数形)を優先して使用しています。line 31 の.hourを.hoursに統一することで、保守性と一貫性が向上します。差分案
- created_at: <%= Time.current - 3.months + 23.hour %> + created_at: <%= Time.current - 3.months + 23.hours %>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@db/fixtures/hibernations.yml` at line 31, 行31の created_at の日時式 "Time.current - 3.months + 23.hour" で単数形の .hour を使っていますが、プロジェクト方針に従い Numeric#hours(複数形)に統一してください;具体的には該当式を "Time.current - 3.months + 23.hours" に置き換えてテスト/fixture の動作に問題がないか確認してください。
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@db/fixtures/hibernations.yml`:
- Line 31: 行31の created_at の日時式 "Time.current - 3.months + 23.hour" で単数形の .hour
を使っていますが、プロジェクト方針に従い Numeric#hours(複数形)に統一してください;具体的には該当式を "Time.current -
3.months + 23.hours" に置き換えてテスト/fixture の動作に問題がないか確認してください。
|
@matuaya |
休会情報を持たない休会中ユーザーが存在していたため 新しい休会情報を作成した
d8427ad to
620dfeb
Compare
There was a problem hiding this comment.
🧹 Nitpick comments (1)
db/fixtures/hibernations.yml (1)
15-55: 共通項目をYAMLアンカー化すると保守しやすくなります
scheduled_return_onとreasonが重複しているため、将来の文言変更時に編集漏れが起きやすいです。任意ですがアンカー化を検討してください。♻️ 参考差分
+hbr_default: &hbr_default + scheduled_return_on: <%= Time.current + 30.days %> + reason: 学習時間が取れないため + hibernation3: + <<: *hbr_default user: unhibernated - scheduled_return_on: <%= Time.current + 30.days %> - reason: 学習時間が取れないため created_at: <%= Time.current - 13.days %> hibernation4: + <<: *hbr_default user: autoretire-within-1-hour - scheduled_return_on: <%= Time.current + 30.days %> - reason: 学習時間が取れないため created_at: <%= Time.current - 3.months + 30.minutes %>🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@db/fixtures/hibernations.yml` around lines 15 - 55, The fixtures repeat the fields scheduled_return_on and reason across multiple hibernation entries; extract those shared values into a YAML anchor (e.g., define &default_hibernation with scheduled_return_on: <%= Time.current + 30.days %> and reason: 学習時間が取れないため) and then reference them in each record using the alias (*default_hibernation) or merge key (<<: *default_hibernation) so each hibernation3..hibernation9 reuses the anchored values while keeping created_at and user unique.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@db/fixtures/hibernations.yml`:
- Around line 15-55: The fixtures repeat the fields scheduled_return_on and
reason across multiple hibernation entries; extract those shared values into a
YAML anchor (e.g., define &default_hibernation with scheduled_return_on: <%=
Time.current + 30.days %> and reason: 学習時間が取れないため) and then reference them in
each record using the alias (*default_hibernation) or merge key (<<:
*default_hibernation) so each hibernation3..hibernation9 reuses the anchored
values while keeping created_at and user unique.
休会理由を同じにしていたが、共通化する理由があるのだろうかと勘違いされる 可能性があると感じ、修正した
|
@s-tone-gs |
matuaya
left a comment
There was a problem hiding this comment.
少し遅れてしまい申し訳ないです🙇♀️
休会情報バッチリ表示されていました!Approveさせていただきます
|
|
||
| hibernation3: | ||
| user: unhibernated | ||
| scheduled_return_on: <%= Time.current + 30.days %> |
There was a problem hiding this comment.
なるべくnowやcurrentは使わず固定の時間にして、テストの方でtravel_toを使うやり方のほうがよいかなとおもいます。
なぜなら、現在時刻に依存したテストは再現性が低く、こまったテストになることがおおいからです。
There was a problem hiding this comment.
@komagata
db/fixtures/以下にあるデータは自動テストでは使用されるものではないため、nowやcurrentを使用しても問題ないという認識です。これらは開発環境やステージング環境における、画面上での動作確認において使用されるシードデータだと認識しています。
こちらでも固定の時間にするべきでしょうか?
There was a problem hiding this comment.
すみません、test/fixturesと見間違えていました。修正しなくて大丈夫です。
Issue
概要
休会情報を持たない休会中ユーザーという矛盾したシードデータが存在していたため、開発環境において休会中ユーザーのプロフィールに休会情報が表示されないバグが発生していた。
変更確認方法
rails db:reset※開発環境のデータが全て削除されるので注意してくださいScreenshot
変更前
変更後
Summary by CodeRabbit