Sha256: e5a7b0b0dacfd833854cd1e41d16cda05b83ded17de48f3704e5a6bcf5fa2741
Contents?: true
Size: 1.91 KB
Versions: 5
Compression:
Stored size: 1.91 KB
Contents
require 'test_helper' class PdfRenderingTest < ActionDispatch::IntegrationTest test "pdf request sends a pdf as a file" do get home_path(format: :pdf) assert_match "PDF", response.body assert_equal "binary", headers["Content-Transfer-Encoding"] assert_equal 'inline; filename="contents.pdf"', headers["Content-Disposition"] assert_equal "application/pdf", headers["Content-Type"] end test "pdf renderer uses the specified template" do get another_path(format: :pdf) assert_match "PDF", response.body assert_equal "binary", headers["Content-Transfer-Encoding"] assert_equal "inline; filename=\"contents.pdf\"", headers["Content-Disposition"] assert_equal "application/pdf", headers["Content-Type"] end test "pdf rendering can use partials" do get partials_path(format: :pdf) assert_match "PDF", response.body assert_equal "binary", headers["Content-Transfer-Encoding"] assert_equal "inline; filename=\"contents.pdf\"", headers["Content-Disposition"] assert_equal "application/pdf", headers["Content-Type"] assert_match "I was rendered in a partial", pdf.page(1).text end test "pdf rendering can access helpers" do get helpers_path(format: :pdf) assert_match "PDF", response.body assert_equal "binary", headers["Content-Transfer-Encoding"] assert_equal "inline; filename=\"contents.pdf\"", headers["Content-Disposition"] assert_equal "application/pdf", headers["Content-Type"] assert_match "This string came from a helper", pdf.page(1).text end test "pdf layout can be set in view" do get pdf_layout_path(format: :pdf) assert_match "PDF", response.body assert_equal [0,0,792,612].map(&:to_f), pdf.page(1).attributes[:MediaBox] end test "pdf can use rails layouts for header and footer" do get pdf_layout_path(format: :pdf) assert_match "Header", pdf.page(1).text assert_match "Footer", pdf.page(1).text end end
Version data entries
5 entries across 5 versions & 1 rubygems