From e133ca76a98c2cc36e7838d74196018b56d74c24 Mon Sep 17 00:00:00 2001 From: Lubos Hricak Date: Tue, 1 Aug 2023 08:32:20 -0300 Subject: [PATCH] Fix specs --- app/assets/javascripts/admin/form_answers.js.coffee | 2 +- app/controllers/concerns/assessment_submission_mixin.rb | 7 ++++++- spec/support/shared_contexts/appraisal_form_context.rb | 6 ++++++ 3 files changed, 13 insertions(+), 2 deletions(-) diff --git a/app/assets/javascripts/admin/form_answers.js.coffee b/app/assets/javascripts/admin/form_answers.js.coffee index 4e681d9c7a..0b37b30d13 100644 --- a/app/assets/javascripts/admin/form_answers.js.coffee +++ b/app/assets/javascripts/admin/form_answers.js.coffee @@ -341,7 +341,7 @@ ready = -> message = "Case summary submitted" removeExistingErrorMessages(panel) - container.insertAdjacentHTML('afterbegin', buildBannerHtml(message, 'success')) + panel.insertAdjacentHTML('afterbegin', buildBannerHtml(message, 'success')) $(this).find('input:submit').remove() diff --git a/app/controllers/concerns/assessment_submission_mixin.rb b/app/controllers/concerns/assessment_submission_mixin.rb index a6e7bd4d50..86b97f58e1 100644 --- a/app/controllers/concerns/assessment_submission_mixin.rb +++ b/app/controllers/concerns/assessment_submission_mixin.rb @@ -8,7 +8,7 @@ def create respond_to do |format| format.json { render(json_response) } format.html do - render_flash_message_for(resource, message: resource.errors.none? ? nil : resource.errors.full_messages.join(", ")) + render_flash_message_for(resource, message: flash_message) redirect_to [namespace_name, resource.form_answer] end end @@ -34,6 +34,11 @@ def form_answer private + def flash_message + return nil if resource.errors.none? + resource.errors.full_messages.join(", ") + end + def json_response json = @service.as_json resp = { json: @service.errors } diff --git a/spec/support/shared_contexts/appraisal_form_context.rb b/spec/support/shared_contexts/appraisal_form_context.rb index 3ac3f873df..732ceeb456 100644 --- a/spec/support/shared_contexts/appraisal_form_context.rb +++ b/spec/support/shared_contexts/appraisal_form_context.rb @@ -108,7 +108,11 @@ def assert_description_change(section_id, header_id) expect(page).to have_selector("textarea", count: 1) find("textarea").fill_in(with: text) end + + all(".form-cancel-link").each(&:click) + within parent_selector do + find(".form-edit-link").click find(".form-save-link").click wait_for_ajax end @@ -135,6 +139,8 @@ def assert_multiple_description_change(section_id, header_id, prefix) within section_id do fill_in("#{prefix}_verdict", with: text2) + all(".form-cancel-link").each(&:click) + all(".form-edit-link").last.click all(".form-save-link").last.click wait_for_ajax end