Skip to content

/job_support の下部に就職に関するFAQの一覧を表示する#8807

Merged
komagata merged 11 commits intomainfrom
feature/display_FAQ_bottom_of_/job_support
Aug 25, 2025
Merged

/job_support の下部に就職に関するFAQの一覧を表示する#8807
komagata merged 11 commits intomainfrom
feature/display_FAQ_bottom_of_/job_support

Conversation

@tyrrell-IH
Copy link
Copy Markdown
Contributor

@tyrrell-IH tyrrell-IH commented Jun 18, 2025

Issue

概要

bootcamp.fjord.jp/job_supportのページの下部に「就職についてよくある質問」の項目と、それに関連するFAQが表示されるようにしました。

仕様についての詳細はissueの方をご確認ください。

変更確認方法

  1. feature/display_FAQ_bottom_of_/job_supportをローカルに取り込み、当該ブランチに切り替える。
  • ブランチ取り込み
git fetch origin feature/display_FAQ_bottom_of_/job_support
  • ブランチ切り替え
git checkout feature/display_FAQ_bottom_of_/job_support
  1. セットアップ
bin/setup
  1. ローカルでサーバーを起動する
foreman start -f Procfile.dev
  1. FAQが表示されているかの確認
    表示方法が3パターンあります。
  • FAQが1件以上ある場合

    • /job_supportへ移動する。
    • 最下方へスクロールし、スクリーンショット(変更後)の「FAQが1件以上ある場合」の画像を参考に、以下の内容が表示されているか確認する。
      • 「就職についてよくある質問」というタイトル及び各FAQ
  • FAQが0件かつadmin権限で/job_supporへアクセスしている場合

    • admin権限を持つユーザー[例: komagata]でログインし、/admin/faqsへ移動する。
    • 「就職について」の項目の各FAQの編集ボタンを押し、各FAQを削除する。
    • admin権限のまま/job_supportへ移動する。
    • 最下方へスクロールし、スクリーンショット(変更後)の「FAQが0件かつadmin権限で/job_supporへアクセスしている場合」の画像を参考に、以下の内容を確認
      • 「よくある質問はまだありません」というメッセージ、「よくある質問を追加する」という名称のリンクが存在することを確認する。
      • リンクを押すと/admin/faqs/newへ移動することを確認する。
  • FAQが0件かつ非admin権限で/job_supporへアクセスしている場合

    • 上記「FAQが0件かつadmin権限で/job_supporへアクセスしている場合」の確認にて該当のFAQを全件削除できていることを前提とする。
    • 非admin権限のユーザー(もしくは未ログイン状態)で/job_supportへ移動。
      最下方へスクロールし、スクリーンショット(変更後)の「FAQが0件かつ非admin権限で/job_supporへアクセスしている場合」の画像を参考に、以下の内容を確認
      • FAQに関する項目が何も表示されていない(変更前のスクリーンショットと同じ状態)。

Screenshot

変更前

就職支援___FJORD_BOOT_CAMP(フィヨルドブートキャンプ)

変更後

FAQが1件以上ある場合

_development__就職支援___FJORD_BOOT_CAMP(フィヨルドブートキャンプ)

FAQが0件かつadmin権限で/job_supporへアクセスしている場合

_development__就職支援___FJORD_BOOT_CAMP(フィヨルドブートキャンプ)_と_Release_2025-07-24_10_18_19__0000_by_github-actions_bot__·_Pull_Request__8889_·_fjordllc_bootcamp

FAQが0件かつ非admin権限で/job_supporへアクセスしている場合

_development__就職支援___FJORD_BOOT_CAMP(フィヨルドブートキャンプ)

Summary by CodeRabbit

  • 新機能

    • 就職サポートページに「よくある質問」セクションを追加し、存在する場合はFAQ一覧を表示。未登録時は管理者向けの案内を表示。
    • 研修ページと認定リスキル(Rails開発者コース)のFAQ表示を部分テンプレート化し、表示ロジックを統一。
    • FAQ取得処理を統一し、各ページで一貫した挙動を実現。
  • テスト

    • 就職サポートのFAQ表示に関するシステムテストを追加(表示/非表示/管理者時の追加リンク確認)。
  • 雑務

    • テスト用FAQフィクスチャのカテゴリ名を整理。

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 18, 2025

Walkthrough

WelcomeControllerに就職用カテゴリ定数と共通ヘルパーfaqs_forが追加され、job_support/training/rails_developer_courseがそのヘルパー経由でFAQを取得するようになりました。複数のビューにFAQ部分テンプレが追加・差替えされ、fixturesとシステムテストが更新されています。

Changes

Cohort / File(s) 変更内容概要
Controller
app/controllers/welcome_controller.rb
FAQ_CATEGORY_NAME_FOR_JOB_SUPPORT定数追加。job_support/training/rails_developer_coursefaqs_for(...)でFAQ取得。faqs_for(category_name)プライベートメソッド追加。
Job support views
app/views/welcome/job_support.html.slim, app/views/welcome/job_support/_faqs.html.slim
job_supportページにFAQの条件付きレンダリングを追加。新規部分テンプレ_faqs.html.slimを追加してFAQを列挙表示。
Training views
app/views/welcome/training.html.slim, app/views/welcome/training/_faqs.html.slim
埋め込みFAQマークアップを部分テンプレ化(新規_faqs.html.slim)。FAQが無い場合は管理者向けの未登録フォールバックを表示。
Certified reskill course view
app/views/welcome/certified_reskill_courses/rails_developer_course/index.html.slim
faq部分テンプレート呼び出しを複数形のfaqsへ変更(faqs: @faqsを渡す)。
Fixtures
test/fixtures/faqs.yml
複数FAQエントリのfaq_category値を複数形から単数形へ修正(文字列値の更新)。
System tests
test/system/faqs/job_support_faqs_test.rb
JobSupportFAQsTestを追加。就職FAQの表示・非表示および管理者ログイン時の「よくある質問を追加する」リンク表示を検証するテストを追加。

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant RailsApp as WelcomeController
  participant DB as FAQCategory/FAQ

  Browser->>RailsApp: GET /welcome/job_support
  RailsApp->>DB: FAQCategory.find_by(name: FAQ_CATEGORY_NAME_FOR_JOB_SUPPORT)
  alt category found
    DB-->>RailsApp: category with faqs
    RailsApp->>RailsApp: @faqs = category.faqs.order(:position)
  else not found
    DB-->>RailsApp: nil
    RailsApp->>RailsApp: @faqs = FAQ.none
  end
  RailsApp-->>Browser: render job_support
  alt @faqs.present?
    RailsApp-->>Browser: render _faqs partial (faqs: @faqs)
  else admin user
    RailsApp-->>Browser: render welcome/faqs/faqs_empty partial
  end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • komagata

Poem

ぴょんと跳ねてカテゴリ見つけたよ、就職について🐰
部分テンプレ並べて質問がずらり。
管理者なら「追加する」リンクぴょこん。
テストで確かめて、にんじんで乾杯。

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 RuboCop (1.76.1)
test/system/faqs/job_support_faqs_test.rb

rubocop-minitest extension supports plugin, specify plugins: rubocop-minitest instead of require: rubocop-minitest in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
rubocop-capybara extension supports plugin, specify plugins: rubocop-capybara instead of require: rubocop-capybara in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
Unable to find gem rubocop-fjord; is the gem installed? Gem::MissingSpecError
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:309:in rescue in gem_config_path' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:293:in gem_config_path'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:84:in block (2 levels) in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:82:in reverse_each'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:82:in block in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:76:in each_pair'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:76:in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader.rb:58:in load_file'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_store.rb:29:in options_config=' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:162:in act_on_options'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:47:in block in run' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:82:in profile_if_needed'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:43:in run' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/exe/rubocop:19:in <top (required)>'
/usr/local/bin/rubocop:25:in load' /usr/local/bin/rubocop:25:in

'

app/controllers/welcome_controller.rb

rubocop-minitest extension supports plugin, specify plugins: rubocop-minitest instead of require: rubocop-minitest in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
rubocop-capybara extension supports plugin, specify plugins: rubocop-capybara instead of require: rubocop-capybara in /.rubocop.yml.
For more information, see https://docs.rubocop.org/rubocop/plugin_migration_guide.html.
Unable to find gem rubocop-fjord; is the gem installed? Gem::MissingSpecError
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:309:in rescue in gem_config_path' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:293:in gem_config_path'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:84:in block (2 levels) in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:82:in reverse_each'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:82:in block in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:76:in each_pair'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader_resolver.rb:76:in resolve_inheritance_from_gems' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_loader.rb:58:in load_file'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/config_store.rb:29:in options_config=' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:162:in act_on_options'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:47:in block in run' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:82:in profile_if_needed'
/var/lib/gems/3.1.0/gems/rubocop-1.79.2/lib/rubocop/cli.rb:43:in run' /var/lib/gems/3.1.0/gems/rubocop-1.79.2/exe/rubocop:19:in <top (required)>'
/usr/local/bin/rubocop:25:in load' /usr/local/bin/rubocop:25:in

'

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.


📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 774703c and 1d590ca.

📒 Files selected for processing (7)
  • app/controllers/welcome_controller.rb (5 hunks)
  • app/views/welcome/job_support.html.slim (1 hunks)
  • app/views/welcome/job_support/_faqs.html.slim (1 hunks)
  • app/views/welcome/training.html.slim (1 hunks)
  • app/views/welcome/training/_faqs.html.slim (1 hunks)
  • test/fixtures/faqs.yml (11 hunks)
  • test/system/faqs/job_support_faqs_test.rb (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (7)
  • test/system/faqs/job_support_faqs_test.rb
  • app/views/welcome/job_support/_faqs.html.slim
  • test/fixtures/faqs.yml
  • app/views/welcome/training.html.slim
  • app/views/welcome/training/_faqs.html.slim
  • app/views/welcome/job_support.html.slim
  • app/controllers/welcome_controller.rb
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/display_FAQ_bottom_of_/job_support

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.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tyrrell-IH
Copy link
Copy Markdown
Contributor Author

@coderabbitai review

@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Jun 18, 2025

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 2

♻️ Duplicate comments (1)
app/controllers/welcome_controller.rb (1)

38-40: training アクションでも同様の nil ガードを追加すべきです

上記 job_support と同じロジックなので、同じ不具合が発生します。重複コードを避ける意味でも共通メソッド化を検討してください。

🧹 Nitpick comments (2)
app/controllers/welcome_controller.rb (1)

8-9: 定数は .freeze しておくと誤代入を防げます

- FAQ_CATEGORY_NAME_FOR_TRAINING = '法人利用について'
- FAQ_CATEGORY_NAME_FOR_JOB_SUPPORT = '就職について'
+ FAQ_CATEGORY_NAME_FOR_TRAINING = '法人利用について'.freeze
+ FAQ_CATEGORY_NAME_FOR_JOB_SUPPORT = '就職について'.freeze
app/views/welcome/job_support.html.slim (1)

384-394: @faqs が空・nil の場合の表示崩れ対策

コントローラ側で nil ガードしても、FAQ が 0 件の場合はループが実行されず空セクションになります。以下のように分岐を追加すると UX が向上します。

- if @faqs.present?
  - @faqs.each do |faq|
    ...
- else
  p.lp-faq__empty
    | 現在、就職に関する FAQ はありません。
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 024fd00 and 93cdf29.

📒 Files selected for processing (2)
  • app/controllers/welcome_controller.rb (3 hunks)
  • app/views/welcome/job_support.html.slim (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: build_and_test

@tyrrell-IH tyrrell-IH self-assigned this Jun 18, 2025
@tyrrell-IH tyrrell-IH force-pushed the feature/display_FAQ_bottom_of_/job_support branch 3 times, most recently from 3d6b2b4 to 4c1f769 Compare June 24, 2025 02:11
@tyrrell-IH
Copy link
Copy Markdown
Contributor Author

@machida
/job_support以下のFAQ表示の実装が完了しました。

/training以下のFAQのスタイルをそのまま当てておりますが、デザインの確認をお願いします~

@machida
Copy link
Copy Markdown
Member

machida commented Jun 24, 2025

@tyrrell-IH 了解ですー!連絡ありがとうございます

@tyrrell-IH
Copy link
Copy Markdown
Contributor Author

@machida
少し時間が経っているので、念の為再度メンションさせていただきます🙏

@machida
Copy link
Copy Markdown
Member

machida commented Jul 23, 2025

@tyrrell-IH ありがとうございます!今日、こちらいじっておきますー

@machida machida force-pushed the feature/display_FAQ_bottom_of_/job_support branch 2 times, most recently from a14b6f3 to ca4a4f5 Compare July 23, 2025 09:48
@machida
Copy link
Copy Markdown
Member

machida commented Jul 23, 2025

@tyrrell-IH お待たせしてすいません。最新のmainを取り込んだ上で修正を追加しました。レビューに進めてください🙏

@machida
Copy link
Copy Markdown
Member

machida commented Jul 23, 2025

テストも通りました👍

@machida machida removed their assignment Jul 23, 2025
@tyrrell-IH tyrrell-IH marked this pull request as ready for review July 25, 2025 02:37
@github-actions github-actions bot requested a review from komagata July 25, 2025 02:37
@tyrrell-IH tyrrell-IH requested a review from karlley July 25, 2025 02:37
@tyrrell-IH
Copy link
Copy Markdown
Contributor Author

@karlley
よければレビューお願いできませんでしょうか?

2週間ほどであればレビューの期限を設けていただいて大丈夫です👌
都合がつかないようであれば別の方にお願いしたいと思います
ご検討のほどよろしくお願いします🙏

@karlley
Copy link
Copy Markdown
Contributor

karlley commented Jul 27, 2025

@tyrrell-IH
お疲れ様です!
返信遅くなりすみませんでした💦

よければレビューお願いできませんでしょうか?
2週間ほどであればレビューの期限を設けていただいて大丈夫です👌

承知しました!
ちょっとお時間いただきますが対応させていただきます。
よろしくお願いします!

Copy link
Copy Markdown
Contributor

@karlley karlley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tyrrell-IH
レビュー大変お待たせしました🙇‍♂️
修正内容について問題無さそうです!
パーシャルへの切り出しや命名変更も行われており、とても良いアプローチだなと感じました👍
1点だけ指摘では無いのですがwelcome_controller#job_support に対するsystemテストが存在していないことが気になりました。
ただ、以下の理由かこちらのテストは必須ではないと考えていますので対応はお任せします。

  • controllerに対するテストは必須では無いとの記載有り(https://bootcamp.fjord.jp/reports/3300)
  • welcome_controller#job_support は既存のメソッドなので当PRでテストを追加するべきではなさそう(テストが必要であれば#job_support が追加された時点でテストが追加されているはず)

確認よろしくお願いします!

@tyrrell-IH
Copy link
Copy Markdown
Contributor Author

tyrrell-IH commented Aug 8, 2025

@karlley
もしかしたらテスト必要かもと思って質問タイムで駒形さんに確認したところ、リソース×CRUDアクションに準じるので表示されるかどうかのテスト書いた方が良いとのことでした。
今回job_supportアクション内のFAQCategory.find_by(name: FAQ_CATEGORY_NAME_FOR_JOB_SUPPORT)faq_categoriesテーブルを触っているのでテストが必要になったという認識です。

ご指摘いただきありがとうございました!

テスト作成後再度連絡します〜

@tyrrell-IH tyrrell-IH force-pushed the feature/display_FAQ_bottom_of_/job_support branch from ca4a4f5 to a6c0ec3 Compare August 16, 2025 07:37
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

🔭 Outside diff range comments (1)
test/fixtures/faqs.yml (1)

11-170: faq_categories.yml に未定義のラベルがあります

test/fixtures/faqs.yml で参照している faq_category24 が、test/fixtures/faq_categories.yml に定義されていません。テストで関連解決に失敗します。

対応:

  • test/fixtures/faq_categories.yml に以下のような定義を追加してください
    例)
faq_category24:
  name: 匿名参加
  description: 匿名で参加できることの説明文
  • または、参照先のラベルを既存の番号に修正してください
♻️ Duplicate comments (1)
app/controllers/welcome_controller.rb (1)

21-24: nilガードが追加されNoMethodErrorを回避できています

過去指摘の nil ガードが反映されており、例外を防げています。挙動は training, rails_developer_course と同様で一貫性も取れています。

🧹 Nitpick comments (6)
app/views/welcome/certified_reskill_courses/rails_developer_course/index.html.slim (1)

51-54: FAQ表示の共通化(ViewComponent化)の検討(任意)

本PRで複数ページが同仕様のFAQセクションを持つようになっているため、将来的には ViewComponent(例: FaqSectionComponent)に寄せると見た目・文言・構造の変更を1箇所で管理でき、保守性が上がります。今すぐの必須ではありませんが、継続的な拡張が見込まれる場合は検討の価値があります。

app/controllers/welcome_controller.rb (2)

10-10: カテゴリ名の定数化は良い判断

ビュー/テストと同一のカテゴリ名を定数で集約できており、変更耐性が上がっています。将来的に名称変更の可能性がある場合は、DB側にスラッグを持たせてスラッグで参照する設計も選択肢です(名称変更に強くなります)。


21-24: 重複ロジックのDRY化(任意)

job_support, training, rails_developer_course で同型の代入処理が繰り返されています。プライベートヘルパーに寄せると保守性が上がります。

適用例(この範囲の差分 + 追補コード):

 def job_support
-  category = FAQCategory.find_by(name: FAQ_CATEGORY_NAME_FOR_JOB_SUPPORT)
-  @faqs = category&.faqs || FAQ.none
+  @faqs = faqs_for(FAQ_CATEGORY_NAME_FOR_JOB_SUPPORT)
 end

この変更を支えるプライベートメソッド(該当箇所以外の追加):

private

def faqs_for(category_name)
  FAQCategory.find_by(name: category_name)&.faqs || FAQ.none
end
test/system/faqs/job_support_faqs_test.rb (3)

6-6: テスト側のカテゴリ名の重複定義を避ける

コントローラの定数を参照すれば、名称変更時のテスト破綻を防げます。

-  FAQ_CATEGORY_NAME = '就職について'
+  FAQ_CATEGORY_NAME = WelcomeController::FAQ_CATEGORY_NAME_FOR_JOB_SUPPORT

11-11: 見出しテキストのマッチ方法を空白正規化に強い形へ

改行や空白の差異で不安定になり得るため、正規表現マッチにする方が堅牢です。

-    assert_selector 'h3.lp-content-title', text: "#{FAQ_CATEGORY_NAME}\nよくある質問"
+    assert_selector 'h3.lp-content-title', text: /#{Regexp.escape(FAQ_CATEGORY_NAME)}\s*よくある質問/

27-27: CTA検証をリンク要素+hrefで厳密に

ボタンの見た目クラスではなく、リンクのテキストと遷移先を検証すると誤検知を避けられます。

-    assert_selector '.a-button', text: 'よくある質問を追加する'
+    assert_link 'よくある質問を追加する', href: '/admin/faqs/new'
📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between ca4a4f5 and a6c0ec3.

📒 Files selected for processing (8)
  • app/controllers/welcome_controller.rb (2 hunks)
  • app/views/welcome/certified_reskill_courses/rails_developer_course/index.html.slim (1 hunks)
  • app/views/welcome/job_support.html.slim (1 hunks)
  • app/views/welcome/job_support/_faqs.html.slim (1 hunks)
  • app/views/welcome/training.html.slim (1 hunks)
  • app/views/welcome/training/_faqs.html.slim (1 hunks)
  • test/fixtures/faqs.yml (11 hunks)
  • test/system/faqs/job_support_faqs_test.rb (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (4)
  • app/views/welcome/job_support/_faqs.html.slim
  • app/views/welcome/training/_faqs.html.slim
  • app/views/welcome/training.html.slim
  • app/views/welcome/job_support.html.slim
🧰 Additional context used
📓 Path-based instructions (2)
**/*.rb

⚙️ CodeRabbit Configuration File

**/*.rb: # refactoring

  • まずFat Controllerを避け、次にFat Modelを避ける。
  • Serviceクラスの乱用を避ける。
  • controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。

Rails Patterns

  • ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
  • 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
  • Viewにpartialを作る場合はViewComponentを使うことを検討する。
  • 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
  • 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)

Files:

  • test/system/faqs/job_support_faqs_test.rb
  • app/controllers/welcome_controller.rb
test/**/*

⚙️ CodeRabbit Configuration File

test/**/*: # Test

  • TestCase名は英語で書く。
  • どうしても避けられない時以外にsystem testでsleepは使わない。

Unit Test

model, helper, decorator, view_componentについてはメソッドを追加した場合は必ず対応したUnit TestのTestCaseを1つは書く。

Files:

  • test/system/faqs/job_support_faqs_test.rb
  • test/fixtures/faqs.yml
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (2)
test/fixtures/faqs.yml (1)

11-170: fixtures内の関連名の統一はOK

faq_category: faq_category* への統一で、関連(belongs_to :faq_category)の表現として整合しています。この変更自体は妥当です。

app/views/welcome/certified_reskill_courses/rails_developer_course/index.html.slim (1)

51-54: FAQ部分テンプレートの呼び出し先変更は妥当(命名の一貫性向上)

faq -> faqs への置き換えと faqs: @faqs のローカル渡しは、他ページと統一されていて分かりやすいです。

@tyrrell-IH tyrrell-IH force-pushed the feature/display_FAQ_bottom_of_/job_support branch from fd75f04 to 9b6867d Compare August 16, 2025 17:16
Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 0

♻️ Duplicate comments (1)
app/controllers/welcome_controller.rb (1)

79-81: faqs_for の実装は適切。faqアクションにも適用して NoMethodError の可能性を潰しましょう
FAQCategory.find_by(name: params[:category]).faqs を使っている faq アクション(Line 32-37 付近)は、無効な category パラメータで 500 になり得ます。ここも faqs_for を使って統一すると安全です(以前の指摘と同趣旨)。

以下の変更をご検討ください(選択行以外の変更提案のため参考diffです):

--- a/app/controllers/welcome_controller.rb
+++ b/app/controllers/welcome_controller.rb
@@
   if params[:category].present?
-    faq_category = FAQCategory.find_by(name: params[:category])
-    @faqs = faq_category.faqs
+    @faqs = faqs_for(params[:category])
   else
     @faqs = FAQ.order(:position)
   end

残存パターンの洗い出し用スクリプトです(レポジトリルートで実行)。find_by(name: ...).faqs の直呼びが他にないか確認できます。

#!/bin/bash
set -euo pipefail

echo "Scanning for potential nil-unsafe usages of find_by(name: ...).faqs ..."
rg -nPU -C2 --type rb '(?s)FAQCategory\.find_by\s*\(\s*name:\s*.*?\)\s*\.\s*faqs\b'
🧹 Nitpick comments (1)
app/controllers/welcome_controller.rb (1)

10-10: FAQカテゴリ名の定数追加はOK。ただし「名前」依存は脆いので将来的に slug 等への切り替えを検討を
DB上のカテゴリ名に依存すると、名称変更(管理画面から編集可能な場合など)で表示が壊れます。恒久的キー(slug/key カラム)で参照する設計へ移行できると堅牢です。現状は faqs_forFAQ.none で安全にフォールバックするので、緊急度は低です。

カテゴリ名は運用上変更されない前提でしょうか?変更されうる場合は、将来的に find_by(slug: ...) へ移行する方針のご検討をお願いします。

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL
Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between fd75f04 and 9b6867d.

📒 Files selected for processing (2)
  • app/controllers/welcome_controller.rb (5 hunks)
  • test/system/faqs/job_support_faqs_test.rb (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • test/system/faqs/job_support_faqs_test.rb
🧰 Additional context used
📓 Path-based instructions (1)
**/*.rb

⚙️ CodeRabbit Configuration File

**/*.rb: # refactoring

  • まずFat Controllerを避け、次にFat Modelを避ける。
  • Serviceクラスの乱用を避ける。
  • controller concernを作ろうとしたらPORO(Plain Old Ruby Object)やActiveRecordモデルでの実装で代替できないか検討する。

Rails Patterns

  • ViewHelperにメソッドを実装する時にはまずDecoratorパターンを使うことを検討する。(active_decorator gemを導入しているのでそれを使う)
  • 複雑なActiveRecordクエリがあり、再利用できそうな場合はQueryObjectパターンを検討する。(rails-patterns gemを導入しているのでそれのQuery機能を使う)
  • Viewにpartialを作る場合はViewComponentを使うことを検討する。
  • 複数のActiveRecordモデルを操作する1つの責務がある時や外部APIとやりとりする処理がある場合にはInteractorオブジェクトパターンを検討する。(interactor gemを導入しているのでそれを使う)
  • 複数のInteractorを実行するような処理がある場合Organizerオブジェクトパターンを検討する。(interactor gemを導入しており、その中にOrganizerの機能があるので使う)

Files:

  • app/controllers/welcome_controller.rb
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: build_and_test
🔇 Additional comments (3)
app/controllers/welcome_controller.rb (3)

21-23: job_support: 共通ヘルパーでの取得に統一できていて良い(nilセーフ、並び順もOK)
重複排除できており、カテゴリ未存在時も FAQ.none で安全に扱えるため、ビュー側の3パターン分岐にフィットします。


41-41: training: FAQ取得の共通化は適切
従来の find_by(...).faqs 直呼びからの移行で例外要因を低減できています。


61-61: rails_developer_course: 共通ヘルパー適用は妥当
カテゴリ未存在時のフォールバックも含め、挙動が統一されていて良いです。

@tyrrell-IH tyrrell-IH force-pushed the feature/display_FAQ_bottom_of_/job_support branch from 9b6867d to 5091f36 Compare August 17, 2025 02:01
@tyrrell-IH
Copy link
Copy Markdown
Contributor Author

tyrrell-IH commented Aug 17, 2025

@karlley
遅くなりました、テストの作成およびその他の修正を行いましたのでレビューお願いします🙏

テストに関する修正

  • テストの追加
    commit: 3d96b98
  • fixturesファイルの修正
    commit: ad7e2c4
  • 類似のテストを共通のディレクトリに配置
    commit: 520a293

参考のPR

codeRabbitの指摘

commit: 342cab7
commit: 84e86a6
commit: f759c2f
commit: 5091f36

Copy link
Copy Markdown
Contributor

@karlley karlley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tyrrell-IH
大変お待たせしました🙇‍♂️
テストの追加対応ありがとうございました。
ディレクトリの整理やリファクタリングもされており、とても見やすかったです!
問題無さそうなのでApproveさせていただきました😄

@tyrrell-IH tyrrell-IH force-pushed the feature/display_FAQ_bottom_of_/job_support branch from 5091f36 to 774703c Compare August 21, 2025 23:04
@tyrrell-IH tyrrell-IH force-pushed the feature/display_FAQ_bottom_of_/job_support branch from 774703c to 1d590ca Compare August 22, 2025 23:25
@tyrrell-IH
Copy link
Copy Markdown
Contributor Author

@komagata
チームメンバーのレビューが終わりましたので、レビューお願いします!

Copy link
Copy Markdown
Member

@komagata komagata left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

確認させて頂きました。OKです〜🙆‍♂️

@komagata komagata merged commit 4cb4050 into main Aug 25, 2025
5 checks passed
@komagata komagata deleted the feature/display_FAQ_bottom_of_/job_support branch August 25, 2025 07:17
@github-actions github-actions bot mentioned this pull request Aug 25, 2025
24 tasks
@tyrrell-IH
Copy link
Copy Markdown
Contributor Author

tyrrell-IH commented Sep 7, 2025

@komagata @machida

/job_supportおよび/trainingにおいて

  • 管理者権限でログイン、かつFAQが0件の時に

以下の画像
image
が表示され、かつリンクが正しく動作するか
本番環境にてご確認いただきたいです🙏

できれば

  • 管理者権限でログインしていない、かつFAQが0件の時に

以下の画像
image
が表示されているかを確認したいので
FAQが0件の時に @tyrrell-IH までご連絡いただきたいです🙏

@machida
Copy link
Copy Markdown
Member

machida commented Sep 7, 2025

本番で確認できました 🎉

@coderabbitai coderabbitai bot mentioned this pull request Nov 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants