mirror of
https://ghfast.top/https://github.com/discourse/discourse-shared-edits.git
synced 2026-07-15 11:17:01 +08:00
Major overhaul of the shared edits plugin to improve reliability, robustness, and developer experience: **Backend** - Extract Revise service for cleaner controller orchestration - Add StateValidator for base64/Yjs safety, corruption detection, and recovery - Centralize protocol constants (Ruby + JS) to avoid hardcoded strings - Add state hash sync verification and vector validation endpoints - Harden security (guardian checks), error handling, and resource cleanup - Resize shared edit columns migration; add state_hash column **Frontend** - Decompose shared-edit-manager into focused modules: yjs-document, markdown-sync, rich-mode-sync, network-manager, encoding-utils - Add cursor overlay and caret coordinate tracking for selection sharing - Add ProseMirror extension for rich-mode collaborative editing - Cache-busted Yjs bundle loading via hashed filenames - Fix scroll drift during sync **Testing & Tooling** - Extensive new specs: state_validator, revision_controller, model, revise service - New Ember acceptance tests: cursor, lifecycle, sync flows - Add support scripts: fake_writer (Playwright), state_corruptor, debug_recovery - Add support/lint wrapper for full CI lint suite - Update dependencies and rebuild Yjs/y-prosemirror bundles
56 lines
1.6 KiB
Ruby
56 lines
1.6 KiB
Ruby
# frozen_string_literal: true
|
|
|
|
RSpec.describe Guardian do
|
|
fab!(:moderator)
|
|
fab!(:admin)
|
|
fab!(:user)
|
|
|
|
describe "#can_toggle_shared_edits?" do
|
|
context "when shared_edits_enabled is true" do
|
|
before { SiteSetting.shared_edits_enabled = true }
|
|
|
|
it "disallows shared edits from anon" do
|
|
expect(Guardian.new.can_toggle_shared_edits?).to eq(false)
|
|
end
|
|
|
|
it "disallows shared edits for tl3 users" do
|
|
user.trust_level = 3
|
|
expect(Guardian.new(user).can_toggle_shared_edits?).to eq(false)
|
|
end
|
|
|
|
it "disallows shared edits for regular users" do
|
|
expect(Guardian.new(user).can_toggle_shared_edits?).to eq(false)
|
|
end
|
|
|
|
it "allows shared edits for moderators" do
|
|
expect(Guardian.new(moderator).can_toggle_shared_edits?).to eq(true)
|
|
end
|
|
|
|
it "allows shared edits for admins" do
|
|
expect(Guardian.new(admin).can_toggle_shared_edits?).to eq(true)
|
|
end
|
|
|
|
it "allows shared edits for tl4" do
|
|
user.trust_level = 4
|
|
expect(Guardian.new(user).can_toggle_shared_edits?).to eq(true)
|
|
end
|
|
end
|
|
|
|
context "when shared_edits_enabled is false" do
|
|
before { SiteSetting.shared_edits_enabled = false }
|
|
|
|
it "disallows shared edits for admins" do
|
|
expect(Guardian.new(admin).can_toggle_shared_edits?).to eq(false)
|
|
end
|
|
|
|
it "disallows shared edits for moderators" do
|
|
expect(Guardian.new(moderator).can_toggle_shared_edits?).to eq(false)
|
|
end
|
|
|
|
it "disallows shared edits for tl4" do
|
|
user.trust_level = 4
|
|
expect(Guardian.new(user).can_toggle_shared_edits?).to eq(false)
|
|
end
|
|
end
|
|
end
|
|
end
|