Skip to content

特別イベントにブックマーク機能を追加#9554

Open
kutimiti1234 wants to merge 7 commits intomainfrom
feature/make-event-bookmarkable
Open

特別イベントにブックマーク機能を追加#9554
kutimiti1234 wants to merge 7 commits intomainfrom
feature/make-event-bookmarkable

Conversation

@kutimiti1234
Copy link
Contributor

@kutimiti1234 kutimiti1234 commented Jan 27, 2026

Issue

概要

特別イベントにブックマーク機能を追加した

変更確認方法

  1. {feature/make-event-bookmarkable}をローカルに取り込む
  2. /events/994018171へ移動
  3. bookmarkボタンを押す
  4. /current_user/bookmarksへ移動
  5. bookmarkされていることを確認
  6. /events/994018171へ移動し、bookmarkを解除
  7. /current_user/bookmarksへ移動し、一覧から消えていることを確認。

Screenshot

変更前

image

変更後

image

Summary by CodeRabbit

  • 新機能

    • イベントにブックマーク機能を導入しました(イベントを保存・管理可能)。
  • UI

    • イベントヘッダーにブックマークボタンを追加しました(状態表示・切替対応)。
    • イベント表示ラベルを「特別 イベント」に調整しました。
  • テスト

    • ブックマークの操作を検証するシステムテストと関連のテストデータを追加しました。

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

@coderabbitai
Copy link

coderabbitai bot commented Jan 27, 2026

Caution

Review failed

The head commit changed during the review from 2c32cc7 to 08deb91.

📝 Walkthrough

Walkthrough

EventモデルにBookmarkableを組み込み、イベント部分テンプレートにネイティブなブックマークボタンを追加。ラベルヘルパーでEvent用の日本語ラベルを追加し、関連のシステムテスト・fixture を導入。管理画面テンプレートは空白行を整理。

Changes

Cohort / File(s) Summary
モデル統合
app/models/event.rb
BookmarkableモジュールをEventにインクルード。
ビュー — イベント表示
app/views/events/_event.html.slim
イベントヘッダにid="bookmark-button"を持つブックマークボタンを追加(data-bookmarkable-id/data-bookmarkable-type、初期 disabled/aria 状態を含む)。
ヘルパー
app/helpers/label_helper.rb
bookmarkable_labelEvent専用ラベル 特別<br>イベント を明示的に追加。
テスト & fixtures
test/system/bookmark/events_test.rb, test/fixtures/bookmarks.yml, test/helpers/label_helper_test.rb
イベントのブックマークUI挙動を検証するシステムテストを追加。fixturesにbookmark34を追加し、ヘルパーテストを拡張。
管理画面テンプレート(非機能)
app/views/admin/embedding_status/index.html.slim
埋め込み生成コマンド周りの空白行を整理(機能変更なし)。

Sequence Diagram(s)

sequenceDiagram
    participant Browser as Browser
    participant JS as BookmarkJS
    participant Rails as RailsApp
    participant DB as Database

    Browser->>JS: ユーザーが「Bookmark」ボタンをクリック
    JS->>Rails: POST /bookmarks (bookmarkable_type=Event, id=...)
    Rails->>DB: INSERT/DELETE bookmarks
    DB-->>Rails: DB 操作成功
    Rails-->>JS: JSON { status, bookmarked }
    JS-->>Browser: ボタン表示を "Bookmark中" / aria 更新
    Browser->>Rails: GET /current_user/bookmarks(ブックマークリスト表示)
    Rails->>DB: SELECT bookmarks for user
    DB-->>Rails: bookmarks list
    Rails-->>Browser: ブックマークリストを返す
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • okuramasafumi
  • smallmonkeykey

Poem

🐇 ぽんと押せばピョンと光るボタン
小さな庭に印をつけたよ
テストは見守り、データはふかふかで
好きがひとつ、またひとつ増えるよ
おめでとう、ブックマーク! 🥕

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed プルリクエストのタイトルは「特別イベントにブックマーク機能を追加」であり、変更内容の主要な部分(イベントにブックマーク機能を追加)を明確かつ簡潔に要約している。
Description check ✅ Passed プルリクエストの説明は、テンプレートの必須セクション(Issue、概要、変更確認方法、Screenshot)をすべて完備しており、手順は具体的で、スクリーンショットも添付されている。

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/make-event-bookmarkable

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.

@github-project-automation github-project-automation bot moved this to 作業中 in bootcamp Jan 28, 2026
@kutimiti1234 kutimiti1234 force-pushed the feature/make-event-bookmarkable branch 2 times, most recently from 7c12934 to 0929f54 Compare January 28, 2026 12:55
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

🤖 Fix all issues with AI agents
In `@app/assets/stylesheets/application.css`:
- Around line 5-9: The CSS contains Tailwind v4 directives (`@source`, `@theme`,
`@import` "tailwindcss") which Biome's CSS linter doesn't natively support; update
biome.json to add the stylesheet directory to the "ignores" array (so Biome
skips these files) or disable the CSS linter in Biome config; target the file
patterns that match the CSS files containing `@source/`@theme directives when
editing the "ignores" list.
🧹 Nitpick comments (1)
app/assets/stylesheets/application/blocks/page-content/_page-content-header-actions.css (1)

16-64: 重複セレクタを統合して可読性を上げたい。

同一セレクタの定義が複数箇所に散らばっており、将来の修正で差分がズレやすい状態です。1箇所にまとめるのを推奨します。

♻️ まとめる場合の一例
-@media (min-width: 40em) {
-  .page-content-header-actions {
-    justify-content: space-between;
-    gap: .5rem;
-  }
-}
-
-.page-content-header-actions {
-  padding-top: .25rem;
-  display: flex;
-  flex-wrap: wrap;
-}
-
-.page-content-header-actions__start {
-  justify-content: flex-start;
-}
-
-.page-content-header-actions__start,
-.page-content-header-actions__end {
-  display: flex;
-}
-
-@media (min-width: 40em) {
-  .page-content-header-actions__start, .page-content-header-actions__end {
-    flex: 1 1;
-    gap: .5rem;
-  }
-}
+/* 既存ブロックへ統合 */
+.page-content-header-actions {
+  padding-top: .25rem;
+  display: flex;
+  flex-wrap: wrap;
+}
+@media (min-width: 40em) {
+  .page-content-header-actions {
+    justify-content: space-between;
+    gap: .5rem;
+  }
+}
+@media (max-width: 35.9375em) {
+  .page-content-header-actions {
+    justify-content: center;
+    gap: .25rem;
+  }
+}
+
+.page-content-header-actions__start,
+.page-content-header-actions__end {
+  display: flex;
+}
+.page-content-header-actions__start {
+  justify-content: flex-start;
+}
+.page-content-header-actions__end {
+  justify-content: flex-end;
+}
+@media (min-width: 40em) {
+  .page-content-header-actions__start,
+  .page-content-header-actions__end {
+    flex: 1 1;
+    gap: .5rem;
+  }
+}
+@media (max-width: 35.9375em) {
+  .page-content-header-actions__end {
+    gap: .25rem;
+  }
+}

@fjordllc fjordllc deleted a comment from coderabbitai bot Jan 28, 2026
@kutimiti1234 kutimiti1234 force-pushed the feature/make-event-bookmarkable branch from 0929f54 to 805c7ed Compare January 28, 2026 13:21
@kutimiti1234 kutimiti1234 removed this from bootcamp Jan 28, 2026
@kutimiti1234 kutimiti1234 force-pushed the feature/make-event-bookmarkable branch from bcba813 to c1fbcaf Compare January 28, 2026 14:11
@kutimiti1234
Copy link
Contributor Author

@djkazunoko
お疲れ様です。
こちらのPRのレビューしていただくこと可能でしょうか?

@tyrrell-IH
Copy link
Contributor

tyrrell-IH commented Jan 29, 2026

@kutimiti1234
お疲れ様です!
レビュー依頼中にすいません🙏

以前私も似たようなIssue・PRの対応(定期イベントにブックマークボタンを追加 by tyrrell-IH · Pull Request #9306 · fjordllc/bootcamp)をしましたが、ブックマークのラベル内の文字の折り返し対応について確認したいです。

私の実装では↓ではなく
image

↓になるように対応しました。
image

できれば同じような実装になるように調整したいので、現状どんな方針なのか教えていただけたら幸いです〜

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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
app/javascript/components/BookmarksInDashboard.jsx (1)

123-132: Event 型に「定期イベント」ラベルが表示される点は実装上の問題です。

API レスポンスには各モデル型に対する正しいi18n翻訳(modelNameI18n)が含まれており、event は「特別イベント」、regular_event は「定期イベント」と翻訳されます。現在のコードは両方に同じ「定期イベント」ラベルをハードコーディングしているため、Event 型に対して誤った表示となっています。

修正方法として、RegularEvent のみ特別な表示を行い、EventmodelNameI18n で正しい「特別イベント」ラベルが表示されるようにしてください。

現在のコード
{bookmark.modelName === 'RegularEvent' ||
bookmark.modelName === 'Event' ? (
  <>
    定期
    <br />
    イベント
  </>
) : (
  bookmark.modelNameI18n
)}

@kutimiti1234 kutimiti1234 force-pushed the feature/make-event-bookmarkable branch 3 times, most recently from d85c5dd to db51f40 Compare January 29, 2026 12:04
@kutimiti1234
Copy link
Contributor Author

@kutimiti1234 お疲れ様です! レビュー依頼中にすいません🙏

以前私も似たようなIssue・PRの対応(定期イベントにブックマークボタンを追加 by tyrrell-IH · Pull Request #9306 · fjordllc/bootcamp)をしましたが、ブックマークのラベル内の文字の折り返し対応について確認したいです。

私の実装では↓ではなく image

↓になるように対応しました。 image

できれば同じような実装になるように調整したいので、現状どんな方針なのか教えていただけたら幸いです〜

@tyrrell-IH
ご指摘ありがとうございます。こちらの点、盲点でした。
頂いた情報をもとに、実装を既存のものに寄せさせていただきました!

@tyrrell-IH
Copy link
Contributor

@kutimiti1234
こちらの実装に寄せていただいてありがとうございました🙏

@kutimiti1234 kutimiti1234 force-pushed the feature/make-event-bookmarkable branch from db51f40 to a59c52d Compare January 29, 2026 13:12
@djkazunoko
Copy link
Contributor

@kutimiti1234
お疲れ様です!
来週中に対応いたします!

Copy link
Contributor

@djkazunoko djkazunoko left a comment

Choose a reason for hiding this comment

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

@kutimiti1234
動作確認問題ありませんでした!
2点コメントしましたのでご確認お願いします!

Copy link
Contributor

Choose a reason for hiding this comment

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

#9306 で作成されたこちらのテストですが、日報だけではなく、ブックマークできるその他の全てのモデルの表示も確認したほうがいいように思いました。

Copy link
Contributor Author

Choose a reason for hiding this comment

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

こちらのテストについてですが、そもそもが何のためのテストかというと、app\helpers\label_helper.rbに関するテストかと思います。そのため、特別イベント、定期イベント、その他の表示を加工する必要のないbookmarkの3種類のテストで十分だと考えています。再度検討いただければと思います。

Copy link
Contributor

Choose a reason for hiding this comment

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

こちらのテストの網羅性について@komagataさんに質問してみました!

自分としては当初、「ブックマークできるその他の全てのモデルの表示も確認したほうが安全では?」と考えていました。今回確認した「日報」がたまたま改行されなかっただけで、他のモデルが想定外の表示になる可能性もゼロではない、テストするまでは確定しないと思ったためです。対象数も多くないので、全部書いてもよいのではと感じていました。

komagataさんの回答は「代表例だけでもよいし(現状のまま)、全部書くのもよい。どちらでもいい(実装者判断でOK)。」というものでした。
この処理自体は重要度がそこまで高くないため「特別イベント」「定期イベント」「その他代表例」の3パターンが確認できていれば十分と考えることもできるし、処理が重いテストでもなく対象が数個なら全部書いてもいいとのことでした。

この説明を受けて、自分としても「全モデル網羅までは必須ではない」と思ったため、現状のテスト内容のままで問題ないと判断しました。ですので修正は不要です👍

Comment on lines +35 to +37
.page-content-header-actions__action
button(type="button" id="bookmark-button" data-bookmarkable-id="#{event.id}" data-bookmarkable-type="Event" class="a-bookmark-button a-button is-sm is-block is-inactive is-muted" disabled aria-pressed="false" aria-busy="true")
| Bookmark
Copy link
Contributor

Choose a reason for hiding this comment

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

ブックマークボタンは各ビューで使い回されているので、以下のようにパーシャルに分割するのがいいと思いました。

.page-content-header-actions__action
  = render 'bookmarks/button', bookmarkable: event

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ありがとうございます。
こちらその通りだと考えたので共通化を施しました。

@djkazunoko
Copy link
Contributor

@kutimiti1234
追加でもう1点です!

ダッシュボード > 最新のブックマークで特別イベントの文言の改行が反映されていないので以下のファイルに変更が必要かと思います。
https://github.com/fjordllc/bootcamp/blob/main/app/javascript/components/BookmarksInDashboard.jsx

(将来的にこのファイルは削除されると思いますが😅 #9045 )

@kutimiti1234 kutimiti1234 force-pushed the feature/make-event-bookmarkable branch 3 times, most recently from cf94fe3 to 9e6eeed Compare February 8, 2026 13:42
@kutimiti1234 kutimiti1234 force-pushed the feature/make-event-bookmarkable branch from 9e6eeed to 14f52dd Compare February 8, 2026 14:09
@kutimiti1234
Copy link
Contributor Author

@djkazunoko
ラベルのヘルパーメソッドのテスト以外対応させていただきました。
再度のレビューをお願い致します。
※ラベルのヘルパーメソッドのテストについて自分の考えを上で変身させていただきました。ご確認ください。

@djkazunoko
Copy link
Contributor

djkazunoko commented Feb 14, 2026

@kutimiti1234 さんの実装ではないですが、app/models/regular_event.rbinclude Bookmarkableを追加する必要があると思います。

@tyrrell-IH
Copy link
Contributor

tyrrell-IH commented Feb 14, 2026

@kutimiti1234
@djkazunoko
すいません、#9554 (comment) のご指摘については私のミスですね🙏

Bookmark側からの関連(bookmark.bookmarkable)で辿れていたので、RegularEvent側からの関連付けを完全に見落としていました。

RegularEventモデル側にinclude Bookmarkableしないとregular_event.bookmarksのような関連で引けないのと、定期イベントがブックマーク対象であることが明示的でないので修正した方が良いですね。

RegularEventモデルの修正は本PRのスコープ外で本来私の方で別途Issueを立てる事案かと思いますが、クチミチさんの方にこのまま修正お願いしても大丈夫ですか?

こちらで別途Issue立てるでも全然大丈夫ですので、必要であればおっしゃってください〜🙏

@djkazunoko
Copy link
Contributor

@tyrrell-IH @kutimiti1234
include Bookmarkableしないとdependent: :destroyが付かないので、現状定期イベントが削除されても定期イベントに紐づくブックマークが削除されず、その状態で/current_user/bookmarksにアクセスするとエラーが出ます。

このPRで修正していいと思います!

@tyrrell-IH
Copy link
Contributor

@djkazunoko
あーなるほど、その点全く考慮に入れていませんでした。結構ヤバめのバグかなと思うのでご指摘いただいて大変助かりました🙇‍♀️

@kutimiti1234 kutimiti1234 force-pushed the feature/make-event-bookmarkable branch from 2c32cc7 to 08deb91 Compare February 15, 2026 07:54
@kutimiti1234
Copy link
Contributor Author

@tyrrell-IH @djkazunoko
お二人ともご説明ありがとうございます。
恐らく私一人では気づけなかったのでご指摘いただきありがとうございます。

@djkazunoko
上記対応しましたので再度のレビューをお願い致します!

Copy link
Contributor

@djkazunoko djkazunoko left a comment

Choose a reason for hiding this comment

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

対応ありがとうございます!
Approveさせていただきました〜

@kutimiti1234
Copy link
Contributor Author

@djkazunoko
ご対応ありがとうございました!

@okuramasafumi
生徒間レビュー終わりましたので、レビューをお願い致します!

Copy link
Contributor

@okuramasafumi okuramasafumi left a comment

Choose a reason for hiding this comment

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

良さそうです、LGTM!

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