mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Refactor: match url with regexp
And remove unnecessary button click.
This commit is contained in:
@@ -574,12 +574,12 @@ describe '
|
||||
|
||||
context "can bulk print invoices" do
|
||||
def extract_pdf_content
|
||||
pdf_href = page.all('a').pluck('href')
|
||||
page.find(class: "button", text: "VIEW FILE").click
|
||||
invoice_file_number = pdf_href[0][45..59]
|
||||
invoice_path = "tmp/invoices/#{invoice_file_number}.pdf"
|
||||
reader = PDF::Reader.new(invoice_path)
|
||||
# Extract last part of invoice URL
|
||||
link = page.find(class: "button", text: "VIEW FILE")
|
||||
filename = link[:href].match %r{/invoices/.*}
|
||||
|
||||
# Load invoice temp file directly instead of downloading
|
||||
reader = PDF::Reader.new("tmp/#{filename}.pdf")
|
||||
reader.pages.map(&:text)
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user