このコミットが含まれているのは:
2026-10-12 03:45:11 +09:00
コミット 4164c3c3f7
29個のファイルの変更、1014行の追加、382行の削除
+15 -22
ファイルの表示
@@ -2,10 +2,11 @@ require 'digest'
require 'rails_helper'
RSpec.describe Wiki::Commit do
include WikiRecords
let(:user) { create_member_user! }
def create_page title:, body: 'initial body'
described_class.create_content!(
seed_wiki_page(
tag_name: create(:tag_name, name: title),
body:,
created_by_user: user,
@@ -13,26 +14,18 @@ RSpec.describe Wiki::Commit do
end
describe '.create_content!' do
it 'creates page, revision, and version with normalised body' do
expect {
described_class.create_content!(
tag_name: create(:tag_name, name: 'commit_integrity_create'),
body: "a\r\nb\r\n\r\n",
created_by_user: user,
message: 'init')
}
.to change(WikiPage, :count).by(1)
.and change(WikiRevision, :count).by(1)
.and change(WikiVersion, :count).by(1)
page = WikiPage.joins(:tag_name).find_by!(tag_names: { name: 'commit_integrity_create' })
revision = page.current_revision
version = page.wiki_versions.order(:version_no).last
expect(page.body).to eq("a\nb")
expect(revision.lines_count).to eq(2)
expect(version.body).to eq("a\nb")
expect(version.reason).to eq('init')
[:create_content!, :create_legacy_content!].each do |operation|
it "freezes #{ operation } without adding page or history" do
name = create(:tag_name, name: 'Help:frozen_service')
counts = [WikiPage.count, WikiRevision.count, WikiVersion.count]
begin
described_class.public_send(operation, tag_name: name, body: 'initial',
created_by_user: user)
rescue ActiveRecord::RecordInvalid
# A validation rejection is allowed; persistence is not.
end
expect([WikiPage.count, WikiRevision.count, WikiVersion.count]).to eq(counts)
end
end
it 'rejects body that becomes blank after normalisation' do
@@ -80,7 +73,7 @@ RSpec.describe Wiki::Commit do
tag = create(:tag, primary_tag_name: tag_name, category: :general)
page =
described_class.create_content!(
seed_wiki_page(
tag_name:,
body: 'before',
created_by_user: user,