Skip to content

Commit

Permalink
Fixes validation error (#1895)
Browse files Browse the repository at this point in the history
Co-authored-by: Robert-Anthony Lee-Faison <[email protected]>
  • Loading branch information
hectorcorrea and leefaisonr authored Aug 13, 2024
1 parent cb8bd71 commit ab29591
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
1 change: 1 addition & 0 deletions app/controllers/works_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -389,6 +389,7 @@ def process_updates
# This is needed for rendering HTML views with validation errors
@uploads = @work.uploads
@form_resource_decorator = FormResourceDecorator.new(@work, current_user)
@work_decorator = WorkDecorator.new(@work, current_user)

# return 200 so the loadbalancer doesn't capture the error
render :edit
Expand Down
14 changes: 14 additions & 0 deletions spec/system/work_edit_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,20 @@
end
end

context "when introducing errors while editting " do
let(:work) { FactoryBot.create(:awaiting_approval_work) }
let(:curator) { FactoryBot.create(:user, groups_to_admin: [work.group]) }

it "reports the errors to the user" do
sign_in curator
visit edit_work_path(work)
click_on "Curator Controlled"
fill_in "resource_type", with: "invalid value"
click_on "Save Work"
expect(page).to have_content("error prohibited")
end
end

context "for PRDS works" do
let(:work) { FactoryBot.create(:distinct_cytoskeletal_proteins_work) }
let(:user) { work.created_by_user }
Expand Down

0 comments on commit ab29591

Please sign in to comment.