← Back to Upcase

PDF partial interferes with previously-running specs


(Jon Seidel) #1

Another oddity while adding PDF forms to an existing app. I create the PDF forms using WickedPDF and wkhtmotopdf on Heroku and that’s all working fine. My forms are built up of various partials, like so:

In show.html.haml
  #Stuff here for links/actions
  render partial "form_header"...
  render partial: 'form_body"...
  render partial "form_footer"...
  #More stuff here for links/actions

To get the PDF form working, I created the following:

In show.pdf.haml
  render partial: "form_header, :formats => [:haml], :handlers => [:pdf]
  render partial: "form_body, :formats => [:haml], :handlers => [:pdf]
  render partial: "form_footer, :formats => [:haml], :handlers => [:pdf]

This allows me to reuse the existing partials rather than re-creating the entire form. In the process of making the updates, I inadvertently created a partial “_form_body_pdf.haml” and this caused one of my examples to fail:

  scenario "user must provide position comments" do
    click_on "New employee requisition"
    expect(page).to have_content "New Employee Requisition"
    fill_in_sample_page
    fill_in("ee_requisition_position_comments", :with => ' ')
    click_on "Create Ee requisition"
    expect(page).to have_content "Position comments can't be blank"
  end

I get the error message:

Failure/Error: expect(page).to have_content "Position comments can’t be blank"
expected there to be content “Position comments can’t be blank” in “\nArborwell :\nEmployee Requisitions\n\n\n\nHome\nIncident Rpt\nAuto Accident Rpt\nEmployee Req\nCheck Req\nPurchase Req\nQuote Req\n\nLogged in as: Arborwell_7739\n\nDisplay Employee Requisition\n\nEe requisition was successfully created.\n\nEdit\n|\nBack\n|\nPDF\n\n\n\n\n\n\nBasic information about the job position\n\n\n\n* Job Title\n\n\nOTHERTREE CLIMBER\n\n* Dept/Region\n\n\nAD - AdminEB - East BaySB - South BayPN - PeninsulaSC - SacramentoOC - Orange CountySD - San DiegoSR - Santa Rosa\n\n* Reports to\n\n\n\n\nSalary Range\n\n\n\n\n\n\n* Start Date\n\n\n\n\n\n(YYYY/MM/DD)\n\n\n\n* Position?\n\n\nNEW - New PositionREP - Replacement\n\nName\n\n\n\n\n* Position Status\n\n\nFTE - Full TimePTE - Part-timeCNS - ConsultantTMP - Temporary\n\n\n\nSummary of Position (Describe additional duties & responsibilities)\n\n\n\n\nPosition Comments\n\n \n\n\nApprovals\n\nManager\n\n\n2nd-Level Manager\n\nFor HR use only\n\nReq#\n\n\nFilled By\n\n\nHire Date\n\n\n\n\n\n\n\n\nEdit\n|\nBack\n|\nPDF\n\n\n\n”

Simply removing that partial makes the example pass…

What the heck is going on here?