Skip to content

Commit

Permalink
Change copy for error message for when attachments are not yet uploaded
Browse files Browse the repository at this point in the history
Choosing a more human-readable message for when the edition is invalid.
  • Loading branch information
lauraghiorghisor-tw committed Oct 4, 2023
1 parent 1e96f8b commit cbbc31e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/controllers/admin/edition_workflow_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion app/models/edition/publishing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {})
Expand Down
14 changes: 13 additions & 1 deletion test/functional/admin/edition_workflow_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit cbbc31e

Please sign in to comment.