OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
Fix form submissions when mixing primer with named submit buttons
Oliver Güntherfbee3b0889bb
diff --git a/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts b/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.tsindex a59569c31b6..9edd40b4135 100644--- a/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts+++ b/frontend/src/app/shared/components/editor/components/ckeditor-augmented-textarea/ckeditor-augmented-textarea.component.ts@@ -144,9 +144,9 @@ export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin implfilter(() => !this.inFlight),this.untilDestroyed(),)- .subscribe((evt) => {+ .subscribe((evt:SubmitEvent) => {evt.preventDefault();- this.saveForm();+ this.saveForm(evt);});}@@ -154,15 +154,22 @@ export class CkeditorAugmentedTextareaComponent extends UntilDestroyedMixin implwindow.OpenProject.pageWasEdited = true;}- public saveForm():void {+ public saveForm(evt?:SubmitEvent):void {this.syncToTextarea();this.inFlight = true;window.OpenProject.pageIsSubmitted = true;- if (this.turboMode) {- navigator.submitForm(this.formElement);- } else {- this.formElement.submit();- }++ setTimeout(() => {+ if (evt?.submitter) {+ (evt.submitter as HTMLInputElement).disabled = false;+ }++ if (this.turboMode) {+ navigator.submitForm(this.formElement, evt?.submitter || undefined);+ } else {+ this.formElement.requestSubmit(evt?.submitter);+ }+ });}public setup(editor:ICKEditorInstance) {diff --git a/modules/documents/spec/features/attachment_upload_spec.rb b/modules/documents/spec/features/attachment_upload_spec.rbindex 2836f214c3b..c5bade94ab7 100644--- a/modules/documents/spec/features/attachment_upload_spec.rb+++ b/modules/documents/spec/features/attachment_upload_spec.rb@@ -29,11 +29,10 @@require 'spec_helper'require 'features/page_objects/notification'-RSpec.describe 'Upload attachment to documents',- js: true,- with_settings: {- journal_aggregation_time_minutes: 0- } do+RSpec.describe 'Upload attachment to documents', :js,+ with_settings: {+ journal_aggregation_time_minutes: 0+ } dolet!(:user) docreate(:user,member_in_project: project,@@ -80,12 +79,12 @@ RSpec.describe 'Upload attachment to documents',perform_enqueued_jobs doclick_on 'Create'- end- # Expect it to be present on the index page- expect(page).to have_selector('.document-category-elements--header', text: 'New documentation')- expect(page).to have_selector('#content img', count: 1)- expect(page).to have_content('Image uploaded on creation')+ # Expect it to be present on the index page+ expect(page).to have_selector('.document-category-elements--header', text: 'New documentation')+ expect(page).to have_selector('#content img', count: 1)+ expect(page).to have_content('Image uploaded on creation')+ enddocument = Document.lastexpect(document.title).to eq 'New documentation'@@ -120,29 +119,29 @@ RSpec.describe 'Upload attachment to documents',perform_enqueued_jobs doclick_on 'Save'- end- # Expect both images to be present on the show page- expect(page).to have_selector('#content img', count: 2)- expect(page).to have_content('Image uploaded on creation')- expect(page).to have_content('Image uploaded the second time')- attachments_list.expect_attached('image.png', count: 4)+ # Expect both images to be present on the show page+ expect(page).to have_selector('#content img', count: 2)+ expect(page).to have_content('Image uploaded on creation')+ expect(page).to have_content('Image uploaded the second time')+ attachments_list.expect_attached('image.png', count: 4)+ end# Expect a mail to be sent to the user having subscribed to all notificationsexpect(ActionMailer::Base.deliveries.size).to eq 1expect(ActionMailer::Base.deliveries.last.to)- .to match_array [other_user.mail]+ .to contain_exactly(other_user.mail)expect(ActionMailer::Base.deliveries.last.subject).to include 'New documentation'endend- context 'with direct uploads (Regression #34285)', with_direct_uploads: true do+ context 'with direct uploads (Regression #34285)', :with_direct_uploads dobefore do- allow_any_instance_of(Attachment).to receive(:diskfile).and_return image_fixture+ allow_any_instance_of(Attachment).to receive(:diskfile).and_return image_fixture # rubocop:disable RSpec/AnyInstanceendit_behaves_like 'can upload an image'diff --git a/spec/features/admin/attribute_help_texts_spec.rb b/spec/features/admin/attribute_help_texts_spec.rbindex ec3d6485546..615c28f4f9b 100644--- a/spec/features/admin/attribute_help_texts_spec.rb+++ b/spec/features/admin/attribute_help_texts_spec.rb@@ -61,6 +61,8 @@ RSpec.describe 'Attribute help texts',editor.attachments_list.expect_attached('image.png')click_button 'Save'+ expect(page).to have_current_path attribute_help_texts_path(tab: :WorkPackage)+expect(instance.help_text).to include 'My attribute help text'expect(instance.help_text).to match /\/api\/v3\/attachments\/\d+\/content/enddiff --git a/spec/features/forums/attachment_upload_spec.rb b/spec/features/forums/attachment_upload_spec.rbindex fb82396e14c..9d0fc1455e9 100644--- a/spec/features/forums/attachment_upload_spec.rb+++ b/spec/features/forums/attachment_upload_spec.rb@@ -62,7 +62,7 @@ RSpec.describe 'Upload attachment to forum message', js: true doeditor.attachments_list.expect_attached('image.png')editor.wait_until_upload_progress_toaster_cleared- show_page = create_page.click_save+ click_button 'Create'expect(page).to have_selector('#content .wiki img', count: 1)expect(page).to have_content('Image uploaded on creation')@@ -82,7 +82,7 @@ RSpec.describe 'Upload attachment to forum message', js: true doeditor.attachments_list.expect_attached('image.png', count: 2)editor.wait_until_upload_progress_toaster_cleared- show_page.click_save+ click_button 'Save'expect(page).to have_selector('#content .wiki img', count: 2)expect(page).to have_content('Image uploaded on creation')@@ -108,7 +108,7 @@ RSpec.describe 'Upload attachment to forum message', js: true doeditor.attachments_list.expect_attached('image.png')editor.wait_until_upload_progress_toaster_cleared- show_page = create_page.click_save+ click_button 'Create'attachments_list.expect_attached('image.png')@@ -122,7 +122,7 @@ RSpec.describe 'Upload attachment to forum message', js: true doeditor.attachments_list.expect_attached('image.png', count: 2)editor.wait_until_upload_progress_toaster_cleared- show_page.click_save+ click_button 'Save'attachments_list.expect_attached('image.png', count: 2)enddiff --git a/spec/features/forums/message_spec.rb b/spec/features/forums/message_spec.rbindex ec5e4b3715b..910df22bf25 100644--- a/spec/features/forums/message_spec.rb+++ b/spec/features/forums/message_spec.rb@@ -28,7 +28,7 @@require 'spec_helper'-RSpec.describe 'messages', js: true do+RSpec.describe 'messages', :js dolet(:forum) docreate(:forum)end@@ -80,14 +80,15 @@ RSpec.describe 'messages', js: true doSeleniumHubWaiter.waitcreate_page.add_text 'There is no message here'- show_page = perform_enqueued_jobs do+ perform_enqueued_jobs docreate_page.click_save- end-- show_page.expect_current_path+ expect(page).to have_text 'There is no message here'+ show_page = Pages::Messages::Show.new(Message.last)+ show_page.expect_current_path- show_page.expect_subject('The message is')- show_page.expect_content('There is no message here')+ show_page.expect_subject('The message is')+ show_page.expect_content('There is no message here')+ endindex_page.visit!click_link forum.name@@ -111,18 +112,21 @@ RSpec.describe 'messages', js: true dologin_as other_user+ show_page = Pages::Messages::Show.new(Message.last)show_page.visit!show_page.expect_no_repliesreply = perform_enqueued_jobs do- show_page.reply 'But, but there should be one'- end+ message = show_page.reply 'But, but there should be one'++ show_page.expect_current_path(message)+ show_page.expect_num_replies(1)- show_page.expect_current_path(reply)- show_page.expect_num_replies(1)+ show_page.expect_reply(subject: 'RE: The message is',+ content: 'But, but there should be one')- show_page.expect_reply(subject: 'RE: The message is',- content: 'But, but there should be one')+ message+ endindex_page.visit!click_link forum.name@@ -159,8 +163,7 @@ RSpec.describe 'messages', js: true doexpect(page).to have_selector('blockquote', text: 'But, but there should be one')# Quoting the first message- show_page.quote(quoted_message: nil,- subject: 'Also quoting the first message',+ show_page.quote(subject: 'Also quoting the first message',content: "Should also work")show_page.expect_num_replies(3)diff --git a/spec/support/pages/messages/create.rb b/spec/support/pages/messages/create.rbindex 4a8e2e53a15..1d4e54e0206 100644--- a/spec/support/pages/messages/create.rb+++ b/spec/support/pages/messages/create.rb@@ -46,8 +46,6 @@ module Pages::Messagesdef click_saveclick_button 'Create'-- Pages::Messages::Show.new(Message.last)enddef created_messagediff --git a/spec/support/pages/messages/show.rb b/spec/support/pages/messages/show.rbindex 152a7ed90d8..824777804dc 100644--- a/spec/support/pages/messages/show.rb+++ b/spec/support/pages/messages/show.rb@@ -57,6 +57,8 @@ module Pages::Messagesclick_button 'Submit'+ expect(page).to have_selector('.forum-message--comments', text:)+Message.lastend@@ -85,6 +87,9 @@ module Pages::Messagessubject_field = find_by_id('reply_subject')subject_field.native.send_keys(:return)+ text = (quoted_message || Message.first).content+ expect(page).to have_selector('.forum-message--comments blockquote', text:)+Message.lastend