Files
warp_engine/spec/migrations_spec.rb
T
mr.zeroandClaude Opus 5 a0fbf1e2b4 A kódbázis kommentek nélkül marad
Kérésre: minden magyarázó komment kikerült a forrásfájlokból — 89 Ruby, 16
TypeScript, 14 Vue, plusz a CSS/JS/CJS. Nem soralapú kereséssel: a Ruby-t a
Ripper tokenizálta, a JS/TS/CSS-t állapotgép járta végig, hogy az URL-ekben,
reguláris kifejezésekben és heredocokban álló // és # jelek helyükön
maradjanak.

Három komment maradt, mert nélkülük nem indul a kód: az entrypoint.sh
shebangja, a vite-env.d.ts hármas perjeles referenciája, és a sanitize
teszt @vitest-environment direktívája (ez utóbbi a magyarázó része nélkül).

Egy helyen kódot is kellett írni: a CommandBlock másolás-hibaágán a komment
volt a catch egyetlen tartalma, és üres blokkot az eslint nem enged — a
copied jelző visszaállítása került a helyére.

A yaml, Dockerfile, Makefile, erb és markdown fájlokat nem érintettem.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
2026-08-20 12:52:47 +02:00

52 lines
1.8 KiB
Ruby

require "rails_helper"
RSpec.describe "Engine migrations" do
ROUND_VERSION = /\A\d{8}0{4}\d{2}\z/
GRANDFATHERED = %w[
20260805000001
20260805000003
20260806000001
20260806000002
].freeze
let(:versions) do
Dir.glob(WarpEngine::Engine.root.join("db/migrate/*.rb"))
.map { |path| File.basename(path)[/\A\d+/] }
end
it "has a migration to check at all" do
expect(versions).not_to be_empty
end
it "numbers every migration uniquely" do
expect(versions).to eq(versions.uniq)
end
it "uses a real timestamp rather than a round hand-written number" do
round = versions.grep(ROUND_VERSION) - GRANDFATHERED
expect(round).to be_empty,
"these would collide with a host that numbers its migrations the " \
"same way on the same day: #{round.join(', ')}. Use a second-resolution " \
"timestamp — `date -u +%Y%m%d%H%M%S` — not a hand-picked round number."
end
it "does not create a table the install generator also creates" do
template = WarpEngine::Engine.root.join(
"lib/generators/warp_engine/install/templates/create_warp_engine_tables.rb"
)
engine_tables = versions.flat_map do |version|
file = Dir.glob(WarpEngine::Engine.root.join("db/migrate/#{version}_*.rb")).first
File.read(file).scan(/create_table :(\w+)/).flatten
end
template_tables = File.read(template).scan(/create_table :(\w+)/).flatten
duplicated = (engine_tables & template_tables) - [ "application_tokens" ]
expect(duplicated).to be_empty,
"the install template and an engine migration both create " \
"#{duplicated.join(', ')} — a host would run CREATE TABLE twice. " \
"A table added after the initial schema belongs in a migration only."
end
end