Skip to content

Commit

Permalink
add test for ActionController#render_to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
westonganger committed Jul 18, 2017
1 parent ee64bfb commit 1f3b86b
Show file tree
Hide file tree
Showing 8 changed files with 13 additions and 18 deletions.
2 changes: 0 additions & 2 deletions test/dummy/app/assets/javascripts/application.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,4 @@
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
// the compiled file.
//
//= require jquery
//= require jquery_ujs
//= require_tree .
2 changes: 0 additions & 2 deletions test/dummy/app/assets/javascripts/pdf.js

This file was deleted.

2 changes: 0 additions & 2 deletions test/dummy/app/assets/javascripts/products.js

This file was deleted.

4 changes: 0 additions & 4 deletions test/dummy/app/assets/stylesheets/pdf.css

This file was deleted.

4 changes: 0 additions & 4 deletions test/dummy/app/assets/stylesheets/products.css

This file was deleted.

3 changes: 1 addition & 2 deletions test/dummy/app/controllers/pdf_controller.rb
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
class PdfController < ApplicationController

def render_pdf
@items=[{:name=> "Hello"},{:name=> "World"}]
@items = [{:name=> "Hello"},{:name=> "World"}]
render "render_pdf.pdf.prawn"
end



end
4 changes: 2 additions & 2 deletions test/dummy/app/views/pdf/render_pdf.pdf.prawn
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
prawn_document do |pdf|
prawn_document(page_layout: :portrait) do |pdf|
pdf.text "Hello There :D"
pdf.text "now it is here: #{pdf.cursor}"
pdf.text "ITems are #{@items.inspect}"
pdf.text "Items are #{@items.inspect}"
pdf.font("Courier") do
pdf.text "Written in Courier because we are inside the block."
end
Expand Down
10 changes: 10 additions & 0 deletions test/dummy/test/unit/render_to_string_test.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
require 'test_helper'
require 'pdf/reader'

class RenderToStringTest < ActiveSupport::TestCase

test "should render_to_string" do
ApplicationController.new.render_to_string("pdf/render_pdf.pdf", locals: {'@items' => []})
end

end

0 comments on commit 1f3b86b

Please sign in to comment.