Skip to content

Commit 84ec133

Browse files
authored
Remove "Experimental" type check for collaborative documents (editable via BlockNote) (#20994)
https://community.openproject.org/wp/68788 Use the block note feature flag and the hocuspocus URL states to assess the possibility of collaboration. Enables testing of collaboration features on pull preview #20924
1 parent 838451c commit 84ec133

File tree

3 files changed

+13
-21
lines changed

3 files changed

+13
-21
lines changed

modules/documents/app/forms/document_form.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ def initialize(oauth_token: nil)
5454
required: true
5555
)
5656

57-
if OpenProject::FeatureDecisions.block_note_editor_active? && model.type&.name == "Experimental"
57+
if OpenProject::FeatureDecisions.block_note_editor_active?
5858
f.block_note_editor(
5959
name: :content_binary,
6060
label: I18n.t("label_document_description"),

modules/documents/app/services/documents/set_attributes_service.rb

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,7 @@ class SetAttributesService < ::BaseServices::SetAttributes
3333
include Attachments::SetReplacements
3434

3535
def set_default_attributes(_params)
36-
model.kind = experimental_block_note_editor_active? ? :collaborative : :classic
37-
end
38-
39-
private
40-
41-
def experimental_block_note_editor_active?
42-
model.type&.name == "Experimental" && OpenProject::FeatureDecisions.block_note_editor_active?
36+
model.kind = OpenProject::FeatureDecisions.block_note_editor_active? ? :collaborative : :classic
4337
end
4438
end
4539
end

modules/documents/spec/services/documents/set_attributes_service_spec.rb

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
RSpec.describe Documents::SetAttributesService do
3434
shared_let(:user) { create(:admin) }
3535
shared_let(:project) { create(:project) }
36-
shared_let(:experimental_type) { create(:document_type, :experimental) }
36+
shared_let(:doc_type) { create(:document_type) }
3737

3838
current_user { user }
3939

@@ -42,23 +42,21 @@
4242
user:,
4343
model: Document.new,
4444
contract_class: Documents::BaseContract
45-
).call(type_id: experimental_type.id, title: "A Document", project:)
45+
).call(type_id: doc_type.id, title: "A Document", project:)
4646
end
4747

4848
describe "#call" do
49-
context "with 'Experimental' document type" do
50-
context "and block note editor feature active", with_flag: { block_note_editor: true } do
51-
it "sets the document kind to 'collaborative'" do
52-
expect(set_attributes_service).to be_success
53-
expect(set_attributes_service.result).to be_collaborative
54-
end
49+
context "with block note editor feature active", with_flag: { block_note_editor: true } do
50+
it "sets the document kind to 'collaborative'" do
51+
expect(set_attributes_service).to be_success
52+
expect(set_attributes_service.result).to be_collaborative
5553
end
54+
end
5655

57-
context "and block note editor feature inactive", with_flag: { block_note_editor: false } do
58-
it "sets the document kind to 'classic'" do
59-
expect(set_attributes_service).to be_success
60-
expect(set_attributes_service.result).to be_classic
61-
end
56+
context "with block note editor feature inactive", with_flag: { block_note_editor: false } do
57+
it "sets the document kind to 'classic'" do
58+
expect(set_attributes_service).to be_success
59+
expect(set_attributes_service.result).to be_classic
6260
end
6361
end
6462
end

0 commit comments

Comments
 (0)