Skip to content

Commit

Permalink
Fix specs
Browse files Browse the repository at this point in the history
  • Loading branch information
Lubosky committed Aug 1, 2023
1 parent eaedce9 commit be6fd8e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 3 deletions.
2 changes: 1 addition & 1 deletion app/assets/javascripts/admin/form_answers.js.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
7 changes: 6 additions & 1 deletion app/controllers/concerns/assessment_submission_mixin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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 }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
authenticity_token: true,
remote: true,
class: "submit-assessment",
"data-type" => "json")
data: { type: "json" })

= hidden_field_tag :assessment_id, assessment.id, id: "#{assessment.position}_assessment_id_submit_appraisal_form_hidden_field"

Expand Down
6 changes: 6 additions & 0 deletions spec/features/assessor/appraisal_form_submission_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,17 @@

it "submits the form" do
allow_any_instance_of(AssessorAssignment).to receive(:valid?).and_return(true)

find("#appraisal-form-primary-heading .panel-title a").click

take_a_nap

within "#section-appraisal-form-primary" do
click_button "Submit appraisal"
end

visit assessor_form_answer_path form_answer

expect(form_answer.assessor_assignments.primary).to be_submitted
end
end
Expand Down
6 changes: 6 additions & 0 deletions spec/support/shared_contexts/appraisal_form_context.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit be6fd8e

Please sign in to comment.