diff --git a/app/controllers/admin/edition_workflow_controller.rb b/app/controllers/admin/edition_workflow_controller.rb index 6272388fc08..69dbe31cb38 100644 --- a/app/controllers/admin/edition_workflow_controller.rb +++ b/app/controllers/admin/edition_workflow_controller.rb @@ -19,7 +19,7 @@ class Admin::EditionWorkflowController < Admin::BaseController rescue_from ActiveRecord::RecordInvalid do redirect_to admin_edition_path(@edition), - alert: "Unable to #{action_name_as_human_interaction(params[:action])} because it is invalid (#{@edition.errors.full_messages.to_sentence}). Please edit it and try again." + alert: "Unable to #{action_name_as_human_interaction(params[:action])} because #{@edition.errors.full_messages.to_sentence.downcase}. Please edit it and try again." end rescue_from Transitions::InvalidTransition do diff --git a/app/models/edition/publishing.rb b/app/models/edition/publishing.rb index 441d761d1fb..0c581eba463 100644 --- a/app/models/edition/publishing.rb +++ b/app/models/edition/publishing.rb @@ -57,7 +57,7 @@ def asset_manager_check_required? end def attachment_uploaded_to_asset_manager! - errors.add(:attachments, "must have finished uploading.") unless uploaded_to_asset_manager? + errors.add(:attachments, "must have finished uploading") unless uploaded_to_asset_manager? end def build_unpublishing(attributes = {}) diff --git a/test/functional/admin/edition_workflow_controller_test.rb b/test/functional/admin/edition_workflow_controller_test.rb index 37f593c6859..d322a750718 100644 --- a/test/functional/admin/edition_workflow_controller_test.rb +++ b/test/functional/admin/edition_workflow_controller_test.rb @@ -169,7 +169,19 @@ class Admin::EditionWorkflowControllerTest < ActionController::TestCase post :submit, params: { id: draft_edition, lock_version: draft_edition.lock_version } assert_redirected_to admin_publication_path(draft_edition) - assert_equal "Unable to submit this edition because it is invalid (Summary can't be blank). Please edit it and try again.", flash[:alert] + assert_equal "Unable to submit this edition because summary can't be blank. Please edit it and try again.", flash[:alert] + end + + test "submission error should read as a sentence when there are multiple validation errors" do + draft_edition.summary = nil + draft_edition.title = nil + attachment = build(:file_attachment_with_no_assets) + draft_edition.attachments << attachment + draft_edition.save!(validate: false) + post :submit, params: { id: draft_edition, lock_version: draft_edition.lock_version } + + assert_redirected_to admin_publication_path(draft_edition) + assert_equal "Unable to submit this edition because title can't be blank, summary can't be blank, and alternative format provider can't be blank. Please edit it and try again.", flash[:alert] end test "submit responds with 422 if missing a lock version" do