WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content

Conversation

@tyrrell-IH
Copy link
Contributor

@tyrrell-IH tyrrell-IH commented Nov 13, 2025

Issue

概要

定期イベントがブックマークできるよう、Bookmarkボタンを追加しました。

変更確認方法

  1. feature/add-bookmark-button-to-regular-eventsをローカルに取り込む
git fetch origin feature/add-bookmark-button-to-regular-events
git checkout feature/add-bookmark-button-to-regular-events
  1. ローカルでサーバーを立ち上げる
foreman start -f Procfile.dev
  1. 修正箇所の確認方法
  • 任意のユーザーでログインする。
  • /regular_eventsへ移動、任意の定期イベントのページを開き、Bookmarkボタンを押しブックマーク登録する。
  • ブックマークした定期イベントが以下のページにそれぞれ表示され、かつリンクをクリックすると該当の定期イベントページに移動することを確認する。
  • ブックマークした定期イベントページに戻り、Bookmark中ボタンを押しブックマークを解除する。
  • ブックマークを解除した定期イベントの表示が以下のページからそれぞれ消えていることを確認する。

Screenshot

変更前

_development__開発MTG___FBC

変更後

_development__開発MTG___FBC _development__開発MTG___FBC _development__ブックマーク一覧___FBC _development__ダッシュボード___FBC

ラベルの改行について

ブックマークリンクのラベルについて

  定期
イベント
_development__ブックマーク一覧___FBC

のように、「定期」の文字の後に改行が入っているのが望ましいですが、何も対応しない状態では

定期イベ
  ント
_development__ダッシュボード___FBC

のように表示されています。

本来であれば適切な位置で改行を挟むことが望ましいと思います。

しかし、各ラベルについて

  • /current_user/bookmarksBookmarks.jsx
  • /(ダッシュボードのブックマーク欄)BookmarksInDashboard.jsx

にてラベルの要素が構築されていますが、各jsxファイルは

にて削除予定です。

2025/11/19の開発ミーティング夜の部にて駒形さん、町田さんに了承を得た上で

  • 本PRでは改行の対応をしない
  • #9181#9205がmainにマージされるのを待って改行の対応をする、という趣旨のIssueを別途作成する。

という流れで処理を進めることにしました。


その他

#9104
上記PRを参考にして、本PRを作成しています。

Summary by CodeRabbit

  • 新機能

    • 通常のイベントページに「ブックマーク」操作を追加しました(ページ上の操作でイベントをブックマーク可能)。
    • ブックマーク済みイベントはユーザーのブックマーク一覧から確認・移動できます。
  • テスト

    • ブックマークの追加・削除と一覧への反映を検証するシステムテストを追加しました。

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Nov 13, 2025

Walkthrough

正規イベントのページヘッダーにブックマーク操作ボタンを追加し、ブックマークの追加・削除とブックマークリスト反映を検証するシステムテストを追加しました。ボタンは初期で無効表示、bookmarkable関連のdata属性とARIA属性を持ちます。

Changes

Cohort / File(s) Summary
ブックマークUIコンポーネント
app/views/regular_events/_regular_event.html.slim
ページヘッダーのアクション領域にブックマークボタンを追加。id="bookmark-button"data-bookmarkable-id / data-bookmarkable-type、CSSクラス(a-bookmark-button, a-button, is-sm, is-block, is-inactive, is-muted)、ARIA属性(aria-pressed="false", aria-busy="true")で初期無効状態をレンダリング。
ブックマーク機能のシステムテスト
test/system/bookmark/regular_events_test.rb
ブックマークの追加・削除とブックマークリスト反映を検証する2件のシステムテストを追加。フィクスチャ regular_events(:regular_event1) を使用し、ボタンラベルの切替とブックマークリストへの反映/除去を確認する。

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

  • 注目箇所:
    • ビューで追加した id / data-* / ARIA 属性が既存のフロントエンドハンドラ(JS)やCSSと衝突しないか確認。
    • システムテストの非同期待機やフレーク対策(JSイベントの安定性)を重点的に確認。

Possibly related PRs

  • BookmarkButton.jsxの非React化 #9104: React コンポーネントからデータ駆動のネイティブボタンへ移行する類似のブックマークボタン導入とテスト追加を扱ったPR(ビューのマークアップとテストロジックに強い関連)。

Poem

🐰 ブックマークをひとつ、ぽんと押す
ヘッダーで光る小さな印(しるし)
イベントは待つ、また会うその日まで
テストも笑う、確かめた証し
ぴょんと保存、夢をしおりに ✨

Pre-merge checks and finishing touches

✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed PRタイトルは定期イベントへのブックマークボタン追加という変更内容を正確に反映している。
Description check ✅ Passed PR説明はテンプレートの必須セクション(Issue、概要、変更確認方法、Screenshot)をすべて記載しており、詳細な確認手順とスクリーンショットが含まれている。
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/add-bookmark-button-to-regular-events

📜 Recent review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e8165b2 and 7d8b9c7.

📒 Files selected for processing (2)
  • app/views/regular_events/_regular_event.html.slim (1 hunks)
  • test/system/bookmark/regular_events_test.rb (1 hunks)
🧰 Additional context used
📓 Path-based instructions (5)
test/**/*_test.rb

📄 CodeRabbit inference engine (AGENTS.md)

test/**/*_test.rb: Test suite should use Minitest with structure: system/, models/, controllers/, and fixtures in test/fixtures/; test files should be named *_test.rb
Use Minitest + Capybara for system tests; place unit and integration tests under matching test/* directories

Files:

  • test/system/bookmark/regular_events_test.rb
**/*.rb

📄 CodeRabbit inference engine (AGENTS.md)

Ruby code should use 2-space indentation, snake_case for method names, and CamelCase for class names, enforced by RuboCop (.rubocop.yml)

Files:

  • test/system/bookmark/regular_events_test.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/bookmark/regular_events_test.rb
test/**

📄 CodeRabbit inference engine (AGENTS.md)

Keep tests deterministic and use fixtures stored in test/fixtures/ for test data

Files:

  • test/system/bookmark/regular_events_test.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/bookmark/regular_events_test.rb
**/*.slim

📄 CodeRabbit inference engine (AGENTS.md)

Slim templates should be linted according to config/slim_lint.yml

Files:

  • app/views/regular_events/_regular_event.html.slim
🧠 Learnings (10)
📓 Common learnings
Learnt from: tyrrell-IH
Repo: fjordllc/bootcamp PR: 9306
File: app/javascript/components/Bookmarks.jsx:248-265
Timestamp: 2025-11-17T00:46:30.794Z
Learning: fjordllc/bootcamp プロジェクトでは、Reactからバニラ JavaScript への移行作業が進行中である。そのため、新しいReactファイルの作成は避け、既存のReactコンポーネント内で完結する実装が推奨される。BookmarksInDashboard.jsx は issue #9045 で削除予定。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:131-135
Timestamp: 2025-09-12T21:18:00.834Z
Learning: Rails アップグレードPRにおいて、product_review_not_completed メソッドの webhook URL 設定の shared フォールバック追加も、設定システム全体の変更として別PRで対応すべきである。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/models/graduation_notifier.rb:23-28
Timestamp: 2025-09-12T21:16:47.639Z
Learning: Rails upgrade PRにおいて、configuration systemの変更やwebhook設定の改善提案も、アップグレードに直接関連しない場合は別PRで対応すべきである。PRのスコープ維持が重要。
Learnt from: jun-kondo
Repo: fjordllc/bootcamp PR: 9104
File: app/javascript/bookmark-button.js:5-11
Timestamp: 2025-09-28T00:36:43.971Z
Learning: fjordllc/bootcampアプリケーションでは現在、各ページにブックマークボタンは1つのみ存在し、Turbo Driveは未使用のため、querySelector での単一要素初期化とDOMContentLoadedのみのイベントリスナーで十分である。
Learnt from: sjabcdefin
Repo: fjordllc/bootcamp PR: 9090
File: app/javascript/user-sns.js:2-25
Timestamp: 2025-08-25T08:00:11.369Z
Learning: app/javascript/user-sns.js において、アクセシビリティ改善(aria-label属性の追加など)は他の箇所との整合性を保つため、別途統一して対応する方針である
📚 Learning: 2025-11-26T08:23:30.927Z
Learnt from: CR
Repo: fjordllc/bootcamp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T08:23:30.927Z
Learning: Applies to test/**/*_test.rb : Use Minitest + Capybara for system tests; place unit and integration tests under matching `test/*` directories

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-11-26T08:23:30.927Z
Learnt from: CR
Repo: fjordllc/bootcamp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T08:23:30.927Z
Learning: Applies to test/**/*_test.rb : Test suite should use Minitest with structure: `system/`, `models/`, `controllers/`, and fixtures in `test/fixtures/`; test files should be named `*_test.rb`

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-09-12T21:18:00.834Z
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:131-135
Timestamp: 2025-09-12T21:18:00.834Z
Learning: Rails アップグレードPRにおいて、product_review_not_completed メソッドの webhook URL 設定の shared フォールバック追加も、設定システム全体の変更として別PRで対応すべきである。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-07-10T12:59:27.807Z
Learnt from: kitarou888
Repo: fjordllc/bootcamp PR: 8277
File: test/models/searcher_test.rb:326-331
Timestamp: 2025-07-10T12:59:27.807Z
Learning: モデルテストにおいて、1つのクラスメソッドの複数の挙動を検証する場合、機能の異なる側面を同じテストメソッドでテストすることは、包括的なテストとして適切である。特に`only_me`のような機能では、異なる検索条件(空文字と具体的な検索語)を使い分けることで、より広範囲な動作保証が可能となる。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-07-23T20:31:13.856Z
Learnt from: jun-kondo
Repo: fjordllc/bootcamp PR: 8977
File: app/controllers/reports_controller.rb:63-63
Timestamp: 2025-07-23T20:31:13.856Z
Learning: fjordllc/bootcampプロジェクトの`app/controllers/reports_controller.rb`において、`create`と`update`アクションは両方とも`report.save_uniquely`を使用し、同じ`:report_save`イベントと`'report.save'`イベントを発行する。これは両方とも本質的に「レポートの保存」操作であり、作成と更新を区別する必要がないためである。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-07-30T07:26:36.599Z
Learnt from: ryufuta
Repo: fjordllc/bootcamp PR: 8992
File: app/models/correct_answer_notifier.rb:23-23
Timestamp: 2025-07-30T07:26:36.599Z
Learning: Railsの標準的なヘルパーメソッド(例:`question_url`、`user_path`など)が通常の方法で使用されている場合、それらの動作テストは不要である。これらのメソッドはRailsフレームワーク自体でテストされており、アプリケーション固有のロジックではないため。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-09-28T00:36:43.971Z
Learnt from: jun-kondo
Repo: fjordllc/bootcamp PR: 9104
File: app/javascript/bookmark-button.js:5-11
Timestamp: 2025-09-28T00:36:43.971Z
Learning: fjordllc/bootcampアプリケーションでは現在、各ページにブックマークボタンは1つのみ存在し、Turbo Driveは未使用のため、querySelector での単一要素初期化とDOMContentLoadedのみのイベントリスナーで十分である。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-11-17T00:46:30.794Z
Learnt from: tyrrell-IH
Repo: fjordllc/bootcamp PR: 9306
File: app/javascript/components/Bookmarks.jsx:248-265
Timestamp: 2025-11-17T00:46:30.794Z
Learning: fjordllc/bootcamp プロジェクトでは、Reactからバニラ JavaScript への移行作業が進行中である。そのため、新しいReactファイルの作成は避け、既存のReactコンポーネント内で完結する実装が推奨される。BookmarksInDashboard.jsx は issue #9045 で削除予定。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-09-04T01:39:22.261Z
Learnt from: Miya096jp
Repo: fjordllc/bootcamp PR: 9102
File: app/controllers/mentor/buzzes_controller.rb:0-0
Timestamp: 2025-09-04T01:39:22.261Z
Learning: fjordllc/bootcamp プロジェクトでは、更新処理の成功時の通知メッセージについて、I18n を使用せずに日本語文字列を直接記述する方針で一貫性を保っている。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
🧬 Code graph analysis (1)
test/system/bookmark/regular_events_test.rb (1)
test/supports/javascript_helper.rb (1)
  • wait_for_javascript_components (5-11)
⏰ 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/views/regular_events/_regular_event.html.slim (1)

35-49: 定期イベント用ブックマークボタンのマークアップは既存仕様と整合していそうです

  • id="bookmark-button"data-bookmarkable-id/type の付け方、a-bookmark-button クラス、is-inactive 初期状態など、既存のブックマークボタンの前提に沿った実装になっていて良さそうです。
  • 初期状態を disabled + aria-busy="true" にしておき、JS 側で有効化・状態反映する前提も妥当だと思います。

このままで問題ない認識です。
Based on learnings, this matches the “1ページ1つのブックマークボタン + querySelector 初期化” 方針です。

test/system/bookmark/regular_events_test.rb (2)

5-23: ブックマーク登録〜一覧遷移までのシナリオテストは十分に網羅されています

  • 未ブックマーク状態の確認 → ボタンクリック → Bookmark中 への文言変化 → /current_user/bookmarks でリンク表示 → そのリンクから定期イベント詳細に戻る、という一連のユースケースが過不足なく検証できています。
  • JS 初期化待ちに wait_for_javascript_components を挟んでいて、DOM 更新待ちも考慮されているので安定性も高そうです。

特に修正は不要に見えます。
Based on learnings, 既存の Bookmark::ProductTest と同等レベルのシナリオになっていると思います。


25-45: トグルによるブックマーク一覧の増減確認も意図どおりカバーできています

  • 同一テスト内で「Bookmark にする → 一覧に出る」→「再訪して Bookmark解除 → 一覧から消える」を確認しており、一覧側との整合性をしっかり検証できています。
  • visit_with_auth / ボタンクリックの後に wait_for_javascript_components を挟んでいて、JS ベースの状態更新を待ってからアサートしている点も良いです。

こちらも現状の構成で問題ないと思います。


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

Comment @coderabbitai help to get the list of available commands and usage tips.

@tyrrell-IH tyrrell-IH force-pushed the feature/add-bookmark-button-to-regular-events branch from 0068292 to f00dbb5 Compare November 14, 2025 01:25
@tyrrell-IH tyrrell-IH marked this pull request as ready for review November 14, 2025 02:32
@tyrrell-IH tyrrell-IH self-assigned this Nov 14, 2025
@tyrrell-IH
Copy link
Contributor Author

tyrrell-IH commented Nov 14, 2025

@machida
定期イベントの詳細ページにブックマークボタンを実装しました。

一応スタイルの確認をしていただいても大丈夫でしょうか?
image

またラベル内の文字が
_development__ブックマーク一覧___FBC

定期イベ
 ント

のようになっているのですが、

 定期
イベント

のようにしたいです。
その点も調整していただきたいのですが可能でしょうか?

@machida
Copy link
Member

machida commented Nov 14, 2025

@tyrrell-IH

定期
br
イベント

このように br タグを入れる対応でお願いしますー🙏

Copy link

@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: 1

♻️ Duplicate comments (1)
app/javascript/components/BookmarksInDashboard.jsx (1)

177-189: コードの重複が存在します。

この関数は Bookmarks.jsx の244-256行目と同一です。Bookmarks.jsx のレビューコメントで提案した共通ユーティリティへの抽出を適用してください。

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f00dbb5 and ca227e6.

📒 Files selected for processing (2)
  • app/javascript/components/Bookmarks.jsx (2 hunks)
  • app/javascript/components/BookmarksInDashboard.jsx (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (2)
app/javascript/components/Bookmarks.jsx (1)
app/javascript/components/BookmarksInDashboard.jsx (1)
  • renderBookmarkLabel (177-189)
app/javascript/components/BookmarksInDashboard.jsx (1)
app/javascript/components/Bookmarks.jsx (1)
  • renderBookmarkLabel (244-256)
⏰ 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)
app/javascript/components/Bookmarks.jsx (1)

184-186: ヘルパー関数の使用は適切です。

renderBookmarkLabel ヘルパーの使用により、ラベル表示ロジックが適切に分離されています。

app/javascript/components/BookmarksInDashboard.jsx (1)

122-124: ヘルパー関数の使用は適切です。

renderBookmarkLabel ヘルパーの使用により、ラベル表示ロジックが適切に分離されています。

@tyrrell-IH tyrrell-IH force-pushed the feature/add-bookmark-button-to-regular-events branch from ca227e6 to 79393ab Compare November 17, 2025 00:39
@tyrrell-IH
Copy link
Contributor Author

@smallmonkeykey
こちらレビューお願いできませんでしょうか?

@smallmonkeykey
Copy link
Contributor

@tyrrell-IH
承知しました!1週間ほどお時間いただければと思います!

@tyrrell-IH
Copy link
Contributor Author

@smallmonkeykey
すいません、ちょっと修正したい箇所があるので一旦レビューを待っていただけませんでしょうか?
修正終わり次第またご連絡いたします

@smallmonkeykey
Copy link
Contributor

@tyrrell-IH
承知しました!ご連絡ありがとうございます!

@tyrrell-IH tyrrell-IH force-pushed the feature/add-bookmark-button-to-regular-events branch from 79393ab to 9cbc3c3 Compare November 21, 2025 03:18
@tyrrell-IH
Copy link
Contributor Author

tyrrell-IH commented Nov 21, 2025

@smallmonkeykey
すいません、修正終わりましたのでレビューしていただいて大丈夫です🙏
私の都合で修正を加えたので、レビュー期間は今日から1 週間で大丈夫ですし、それ以降でも大丈夫です

@regular_event = regular_events(:regular_event1)
end

test 'shows regular event link on list when clicking bookmark button' do
Copy link
Contributor

Choose a reason for hiding this comment

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

質問です!既存のブックマーク関連のテストと違って、RegularEventテストでは 1つのテストで一連の動作をシナリオ的にまとめている構成になっていますが、こちらにした理由はありますか??

Copy link
Contributor Author

@tyrrell-IH tyrrell-IH Dec 2, 2025

Choose a reason for hiding this comment

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

一連の動作をシナリオ的にまとめているわけではないつもりでした〜

以下test/system/bookmark/products_test.rbと比較して意図を説明します

前提

ブックマークボタンを今回実装したわけではないので、ブックマークボタンに関する動作はテストしていないという前提です。

ブックマーク機能は日報にブックマーク機能を実装 by alto-I · Pull Request #2789 · fjordllc/bootcampで日報に初めて導入され、その後ボタンの実装がBookmarkButton.jsxの非React化 by jun-kondo · Pull Request #9104 · fjordllc/bootcampにてバニラJSで実装されており、いずれにおいてもブックマークボタンの動作

  • is-active is-inactiveの切り替えがうまくいくか
  • ボタンをクリックした際にリクエストが飛ぶかどうか

等はtest/system/bookmarks_test.rbtest/integration/api/bookmarks_test.rbで保証されていると考えました。

今回のテストの趣旨

上記の前提を踏まえた上で、今回のPRは「定期イベントにブックマークボタンを追加する」なので、テストの内容を

  • テスト1

    • ブックマークされていない定期イベントにおいて
    • 「ブックマーク」ボタンを押すと
    • ボタンの名称が「ブックマーク中」に変更され
    • current_user/bookmarksにブックマークした定期イベントのリンクが表示される
  • テスト2

    • ブックマークされている定期イベントにおいて
    • 「ブックマークボタン中」ボタンを押すと
    • ボタンの名称が「ブックマーク」に変更され
    • current_user/bookmarksからブックマークした定期イベントのリンクが消える

の2点で良いかなと判断しました。

test/system/bookmark/products_test.rbとの比較

test/system/bookmark/products_test.rbは以下の通りです

class Bookmark::ProductTest < ApplicationSystemTestCase
  setup do
    @product = products(:product1)
  end

  test 'show product bookmark on lists' do
    visit_with_auth '/current_user/bookmarks', 'kimura'
    assert_text @product.title
  end

  test 'show active button when bookmarked product' do
    visit_with_auth "/products/#{@product.id}", 'kimura'
    wait_for_javascript_components
    assert_selector '#bookmark-button.is-active'
    assert_no_selector '#bookmark-button.is-inactive'
  end

  test 'show inactive button when not bookmarked product' do
    visit_with_auth "/products/#{@product.id}", 'komagata'
    wait_for_javascript_components
    assert_selector '#bookmark-button.is-inactive'
    assert_no_selector '#bookmark-button.is-active'
  end

  test 'bookmark product' do
    visit_with_auth "/products/#{@product.id}", 'komagata'
    wait_for_javascript_components
    find('#bookmark-button').click
    wait_for_javascript_components
    assert_selector '#bookmark-button.is-active'
    assert_no_selector '#bookmark-button.is-inactive'

    visit '/current_user/bookmarks'
    assert_text @product.title
  end

  test 'unbookmark product' do
    visit_with_auth "/products/#{@product.id}", 'kimura'
    wait_for_javascript_components
    find('#bookmark-button').click
    wait_for_javascript_components
    assert_selector '#bookmark-button.is-inactive'
    assert_no_selector '#bookmark-button.is-active'

    visit '/current_user/bookmarks'
    assert_no_text @product.title
  end
end

上記のうち

  • show product bookmark on listsについてはブックマークボタンを押した後に/current_user/bookmarksに表示されていることが確認できれば良いと考えたので、個別のテストは不要と考えました。
  • show active button when bookmarked productshow inactive button when not bookmarked productについて、is-activeis-inactiveの切り替えについてはtest/system/bookmarks_test.rbにて動作の確認を行なっているので改めての確認は不要だと考えました。

残るテストはbookmark productunbookmark productであり、これらのテストは上記「今回のテストの趣旨」で述べた内容と一緒です。

なので

RegularEventテストでは 1つのテストで一連の動作をシナリオ的にまとめている構成になっていますが

とありますが、私の認識としては

  • test/system/bookmark/products_test.rbにおける
    • bookmark product
    • unbookmark product
  • test/system/bookmark/regular_events.rbにおける
    • shows regular event link on list when clicking bookmark button
    • updates bookmarks list when toggling bookmark

はそれぞれ同じことをテストしており、テストをまとめたわけでは無いという認識です

Copy link
Contributor

Choose a reason for hiding this comment

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

test/system/bookmark/products_test.rbにおける
bookmark product
unbookmark product

test/system/bookmark/regular_events.rbにおける
shows regular event link on list when clicking bookmark button
updates bookmarks list when toggling bookmark
はそれぞれ同じことをテストしており、テストをまとめたわけでは無いという認識です

すみませんでした。確かにそうですね。

is-active is-inactiveの切り替えがうまくいくか
ボタンをクリックした際にリクエストが飛ぶかどうか
等はtest/system/bookmarks_test.rbやtest/integration/api/bookmarks_test.rbで保証されていると考えました。

「ブックマーク」ボタンを押すと
ボタンの名称が「ブックマーク中」に変更され

この部分をassert_selector '#bookmark-button.is-active'ではなく文言でチェックした理由を理解できました。

私の拙い質問にも丁寧に答えてくださり、ありがとうございます!!

@smallmonkeykey
Copy link
Contributor

@tyrrell-IH
通知に気づいておらず遅くなってすみませんでした…!
1点質問させていただきました!

@tyrrell-IH tyrrell-IH force-pushed the feature/add-bookmark-button-to-regular-events branch from 9cbc3c3 to f243d29 Compare December 2, 2025 02:49
Copy link

@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: 1

📜 Review details

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 9cbc3c3 and f243d29.

📒 Files selected for processing (2)
  • app/views/regular_events/_regular_event.html.slim (1 hunks)
  • test/system/bookmark/regular_events_test.rb (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • app/views/regular_events/_regular_event.html.slim
🧰 Additional context used
📓 Path-based instructions (4)
test/**/*_test.rb

📄 CodeRabbit inference engine (AGENTS.md)

test/**/*_test.rb: Test suite should use Minitest with structure: system/, models/, controllers/, and fixtures in test/fixtures/; test files should be named *_test.rb
Use Minitest + Capybara for system tests; place unit and integration tests under matching test/* directories

Files:

  • test/system/bookmark/regular_events_test.rb
**/*.rb

📄 CodeRabbit inference engine (AGENTS.md)

Ruby code should use 2-space indentation, snake_case for method names, and CamelCase for class names, enforced by RuboCop (.rubocop.yml)

Files:

  • test/system/bookmark/regular_events_test.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/bookmark/regular_events_test.rb
test/**

📄 CodeRabbit inference engine (AGENTS.md)

Keep tests deterministic and use fixtures stored in test/fixtures/ for test data

Files:

  • test/system/bookmark/regular_events_test.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/bookmark/regular_events_test.rb
🧠 Learnings (6)
📓 Common learnings
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:131-135
Timestamp: 2025-09-12T21:18:00.834Z
Learning: Rails アップグレードPRにおいて、product_review_not_completed メソッドの webhook URL 設定の shared フォールバック追加も、設定システム全体の変更として別PRで対応すべきである。
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/models/graduation_notifier.rb:23-28
Timestamp: 2025-09-12T21:16:47.639Z
Learning: Rails upgrade PRにおいて、configuration systemの変更やwebhook設定の改善提案も、アップグレードに直接関連しない場合は別PRで対応すべきである。PRのスコープ維持が重要。
Learnt from: tyrrell-IH
Repo: fjordllc/bootcamp PR: 9306
File: app/javascript/components/Bookmarks.jsx:248-265
Timestamp: 2025-11-17T00:46:30.794Z
Learning: fjordllc/bootcamp プロジェクトでは、Reactからバニラ JavaScript への移行作業が進行中である。そのため、新しいReactファイルの作成は避け、既存のReactコンポーネント内で完結する実装が推奨される。BookmarksInDashboard.jsx は issue #9045 で削除予定。
Learnt from: jun-kondo
Repo: fjordllc/bootcamp PR: 9104
File: app/javascript/bookmark-button.js:5-11
Timestamp: 2025-09-28T00:36:43.971Z
Learning: fjordllc/bootcampアプリケーションでは現在、各ページにブックマークボタンは1つのみ存在し、Turbo Driveは未使用のため、querySelector での単一要素初期化とDOMContentLoadedのみのイベントリスナーで十分である。
Learnt from: mousu-a
Repo: fjordllc/bootcamp PR: 8566
File: app/views/pair_works/_body.html.slim:0-0
Timestamp: 2025-08-31T01:05:07.447Z
Learning: システムテストでボタンやフォーム要素を識別する必要がある場合、動的な値をクラス属性に埋め込むのではなく、id属性やdata属性を使用する。特にJavaScriptでの操作やコントローラーへのデータ送信が不要な場合は、id属性を使用するのが適切。
📚 Learning: 2025-11-26T08:23:30.927Z
Learnt from: CR
Repo: fjordllc/bootcamp PR: 0
File: AGENTS.md:0-0
Timestamp: 2025-11-26T08:23:30.927Z
Learning: Applies to test/**/*_test.rb : Use Minitest + Capybara for system tests; place unit and integration tests under matching `test/*` directories

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-09-12T21:18:00.834Z
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:131-135
Timestamp: 2025-09-12T21:18:00.834Z
Learning: Rails アップグレードPRにおいて、product_review_not_completed メソッドの webhook URL 設定の shared フォールバック追加も、設定システム全体の変更として別PRで対応すべきである。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-07-23T20:31:13.856Z
Learnt from: jun-kondo
Repo: fjordllc/bootcamp PR: 8977
File: app/controllers/reports_controller.rb:63-63
Timestamp: 2025-07-23T20:31:13.856Z
Learning: fjordllc/bootcampプロジェクトの`app/controllers/reports_controller.rb`において、`create`と`update`アクションは両方とも`report.save_uniquely`を使用し、同じ`:report_save`イベントと`'report.save'`イベントを発行する。これは両方とも本質的に「レポートの保存」操作であり、作成と更新を区別する必要がないためである。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-07-10T12:59:27.807Z
Learnt from: kitarou888
Repo: fjordllc/bootcamp PR: 8277
File: test/models/searcher_test.rb:326-331
Timestamp: 2025-07-10T12:59:27.807Z
Learning: モデルテストにおいて、1つのクラスメソッドの複数の挙動を検証する場合、機能の異なる側面を同じテストメソッドでテストすることは、包括的なテストとして適切である。特に`only_me`のような機能では、異なる検索条件(空文字と具体的な検索語)を使い分けることで、より広範囲な動作保証が可能となる。

Applied to files:

  • test/system/bookmark/regular_events_test.rb
📚 Learning: 2025-07-30T07:26:36.599Z
Learnt from: ryufuta
Repo: fjordllc/bootcamp PR: 8992
File: app/models/correct_answer_notifier.rb:23-23
Timestamp: 2025-07-30T07:26:36.599Z
Learning: Railsの標準的なヘルパーメソッド(例:`question_url`、`user_path`など)が通常の方法で使用されている場合、それらの動作テストは不要である。これらのメソッドはRailsフレームワーク自体でテストされており、アプリケーション固有のロジックではないため。

Applied to files:

  • test/system/bookmark/regular_events_test.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 (2)
test/system/bookmark/regular_events_test.rb (2)

1-8: セットアップは適切です。

クラス構造とフィクスチャの読み込みは正しく実装されています。


10-21: JavaScriptコンポーネントの初期化待機が必要です。

ブックマークボタンはJavaScriptで動作するため、products_test.rb と同様に wait_for_javascript_components の呼び出しが必要です。これがないと、JavaScriptの初期化前にテストが実行され、不安定なテストになる可能性があります。

以下のdiffを適用してください:

 test 'shows regular event link on list when clicking bookmark button' do
   visit_with_auth regular_event_path(@regular_event), 'machida'
+  wait_for_javascript_components
   assert_selector '#bookmark-button', text: 'Bookmark'
   click_button 'Bookmark'
+  wait_for_javascript_components
   assert_selector '#bookmark-button', text: 'Bookmark中'

   visit current_user_bookmarks_path
⛔ Skipped due to learnings
Learnt from: komagata
Repo: fjordllc/bootcamp PR: 9101
File: app/notifiers/discord_notifier.rb:131-135
Timestamp: 2025-09-12T21:18:00.834Z
Learning: Rails アップグレードPRにおいて、product_review_not_completed メソッドの webhook URL 設定の shared フォールバック追加も、設定システム全体の変更として別PRで対応すべきである。
Learnt from: jun-kondo
Repo: fjordllc/bootcamp PR: 9104
File: app/javascript/bookmark-button.js:5-11
Timestamp: 2025-09-28T00:36:43.971Z
Learning: fjordllc/bootcampアプリケーションでは現在、各ページにブックマークボタンは1つのみ存在し、Turbo Driveは未使用のため、querySelector での単一要素初期化とDOMContentLoadedのみのイベントリスナーで十分である。

@tyrrell-IH
Copy link
Contributor Author

tyrrell-IH commented Dec 2, 2025

@smallmonkeykey
質問へ回答しました〜
何か質問の意図と違うところがあったら何でも聞いてください〜

あと以下の通り少し修正を加えました。

よろしくお願いします

Copy link
Contributor

@smallmonkeykey smallmonkeykey left a comment

Choose a reason for hiding this comment

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

丁寧に答えてくださりありがとうございます。
理解できましたので、approveします!

@tyrrell-IH tyrrell-IH force-pushed the feature/add-bookmark-button-to-regular-events branch from e8165b2 to 7d8b9c7 Compare December 9, 2025 00:47
@tyrrell-IH
Copy link
Contributor Author

tyrrell-IH commented Dec 10, 2025

@okuramasafumi
お疲れ様です、フィヨルドブートキャンプ受講生のティレルと申します。

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

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