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
[66939] Failed update re-rendered the entire component (#20065)
Marcello Rocha01a7aa12cd98
diff --git a/app/controllers/admin/custom_fields/hierarchy/items_controller.rb b/app/controllers/admin/custom_fields/hierarchy/items_controller.rbindex bb0786ed228..daa9e5de3a4 100644--- a/app/controllers/admin/custom_fields/hierarchy/items_controller.rb+++ b/app/controllers/admin/custom_fields/hierarchy/items_controller.rb@@ -77,6 +77,7 @@ module Admin)end+ # rubocop:disable Metrics/AbcSizedef updateinput = item_inputitem_service@@ -86,15 +87,15 @@ module Adminshort: input[:short],score: input[:score]).either(- lambda do |_|- redirect_to(custom_field_item_path(@custom_field, @active_item.parent), status: :see_other)- end,+ ->(*) { redirect_to(custom_field_item_path(@custom_field, @active_item.parent), status: :see_other) },lambda do |validation_result|add_errors_to_edit_form(validation_result)- render action: :edit+ update_via_turbo_stream(component: ItemComponent.new(item: @active_item, show_edit_form: true))+ respond_with_turbo_streamsend)end+ # rubocop:enable Metrics/AbcSizedef moveitem_servicediff --git a/spec/controllers/admin/custom_fields/hierarchy/items_controller_spec.rb b/spec/controllers/admin/custom_fields/hierarchy/items_controller_spec.rbindex dfa24354829..4dc5d7c9bc7 100644--- a/spec/controllers/admin/custom_fields/hierarchy/items_controller_spec.rb+++ b/spec/controllers/admin/custom_fields/hierarchy/items_controller_spec.rb@@ -132,10 +132,16 @@ RSpec.describe Admin::CustomFields::Hierarchy::ItemsController, with_ee: [:custoendcontext "when validation fails" do- it "renders the new page" do- post :update, params: { custom_field_id: custom_field.id, id: luke.id, label: nil }- expect(response).to be_successful- expect(response).to render_template "edit"+ before do+ allow(controller).to receive(:respond_with_turbo_streams).and_call_original+ allow(controller).to receive(:add_errors_to_edit_form).and_call_original+ end++ it "renders the errors on the page" do+ post :update, params: { custom_field_id: custom_field.id, id: luke.id, label: nil, format: :turbo_stream }++ expect(controller).to have_received(:respond_with_turbo_streams).once+ expect(controller).to have_received(:add_errors_to_edit_form).onceendendend