コミットを比較
2
コミット
| 作成者 | SHA1 | 日付 | |
|---|---|---|---|
|
|
694ed60431 | ||
|
|
493ca749b4 |
+11
@@ -0,0 +1,11 @@
|
||||
class AddForeignKeyOnPostIdAndTagIdInPostTagSections < ActiveRecord::Migration[8.0]
|
||||
def change
|
||||
remove_foreign_key :post_tag_sections, :posts, column: :post_id
|
||||
remove_foreign_key :post_tag_sections, :tags, column: :tag_id
|
||||
|
||||
add_foreign_key :post_tag_sections, :post_tags,
|
||||
column: [:post_id, :tag_id],
|
||||
primary_key: [:post_id, :tag_id],
|
||||
on_delete: :cascade
|
||||
end
|
||||
end
|
||||
生成ファイル
+2
-3
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.0].define(version: 2026_09_21_000000) do
|
||||
ActiveRecord::Schema[8.0].define(version: 2026_09_21_010000) do
|
||||
create_table "active_storage_attachments", charset: "utf8mb4", collation: "utf8mb4_0900_ai_ci", force: :cascade do |t|
|
||||
t.string "name", null: false
|
||||
t.string "record_type", null: false
|
||||
@@ -713,8 +713,7 @@ ActiveRecord::Schema[8.0].define(version: 2026_09_21_000000) do
|
||||
add_foreign_key "post_implications", "posts", column: "parent_post_id"
|
||||
add_foreign_key "post_similarities", "posts"
|
||||
add_foreign_key "post_similarities", "posts", column: "target_post_id"
|
||||
add_foreign_key "post_tag_sections", "posts"
|
||||
add_foreign_key "post_tag_sections", "tags"
|
||||
add_foreign_key "post_tag_sections", "post_tags", column: ["post_id", "tag_id"], primary_key: ["post_id", "tag_id"], on_delete: :cascade
|
||||
add_foreign_key "post_tags", "posts"
|
||||
add_foreign_key "post_tags", "tags"
|
||||
add_foreign_key "post_tags", "users", column: "created_user_id"
|
||||
|
||||
@@ -80,18 +80,25 @@ RSpec.describe PostTag, type: :model do
|
||||
end
|
||||
|
||||
it 'does not load sections for another tag on the same post' do
|
||||
post = create(:post)
|
||||
tag = create(:tag)
|
||||
post_tag = create(:post_tag)
|
||||
post = post_tag.post
|
||||
other_tag = create(:tag)
|
||||
|
||||
post_tag = create(:post_tag, post:, tag:)
|
||||
own_section = create(:post_tag_section,
|
||||
post:,
|
||||
tag: post_tag.tag,
|
||||
begin_ms: 1000,
|
||||
end_ms: 2000)
|
||||
|
||||
create(:post_tag, post:, tag: other_tag)
|
||||
|
||||
create(:post_tag_section,
|
||||
post:,
|
||||
tag: other_tag,
|
||||
begin_ms: 1000,
|
||||
end_ms: 2000)
|
||||
|
||||
expect(post_tag.sections).to be_empty
|
||||
expect(post_tag.reload.sections).to contain_exactly(own_section)
|
||||
end
|
||||
|
||||
it 'allows open-ended sections' do
|
||||
|
||||
新しいイシューから参照
ユーザーをブロックする