prawn-rails 1.4.2 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (73) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +8 -1
  3. data/README.md +16 -2
  4. data/Rakefile +0 -0
  5. data/lib/prawn-rails/config.rb +27 -9
  6. data/lib/prawn-rails/document.rb +5 -19
  7. data/lib/prawn-rails/rails_helper.rb +7 -11
  8. data/lib/prawn-rails/version.rb +1 -1
  9. data/lib/prawn-rails.rb +12 -8
  10. metadata +17 -157
  11. data/test/dummy_app/Rakefile +0 -7
  12. data/test/dummy_app/app/assets/config/manifest.js +0 -3
  13. data/test/dummy_app/app/assets/javascripts/application.js +0 -0
  14. data/test/dummy_app/app/assets/stylesheets/application.css +0 -3
  15. data/test/dummy_app/app/controllers/application_controller.rb +0 -3
  16. data/test/dummy_app/app/controllers/reports_controller.rb +0 -37
  17. data/test/dummy_app/app/mailers/reports_mailer.rb +0 -18
  18. data/test/dummy_app/app/views/layouts/application.html.erb +0 -14
  19. data/test/dummy_app/app/views/reports/custom.pdf.prawn +0 -3
  20. data/test/dummy_app/app/views/reports/custom_disposition.pdf.prawn +0 -3
  21. data/test/dummy_app/app/views/reports/custom_filename.pdf.prawn +0 -3
  22. data/test/dummy_app/app/views/reports/sample.html.erb +0 -1
  23. data/test/dummy_app/app/views/reports/sample.pdf.prawn +0 -40
  24. data/test/dummy_app/app/views/reports/table.pdf.prawn +0 -7
  25. data/test/dummy_app/app/views/reports_mailer/send_report.html.erb +0 -1
  26. data/test/dummy_app/config/application.rb +0 -52
  27. data/test/dummy_app/config/boot.rb +0 -10
  28. data/test/dummy_app/config/database.yml +0 -25
  29. data/test/dummy_app/config/environment.rb +0 -5
  30. data/test/dummy_app/config/environments/development.rb +0 -30
  31. data/test/dummy_app/config/environments/production.rb +0 -60
  32. data/test/dummy_app/config/environments/test.rb +0 -41
  33. data/test/dummy_app/config/initializers/backtrace_silencers.rb +0 -7
  34. data/test/dummy_app/config/initializers/inflections.rb +0 -10
  35. data/test/dummy_app/config/initializers/mime_types.rb +0 -5
  36. data/test/dummy_app/config/initializers/prawn-rails.rb +0 -5
  37. data/test/dummy_app/config/initializers/secret_token.rb +0 -11
  38. data/test/dummy_app/config/initializers/session_store.rb +0 -8
  39. data/test/dummy_app/config/initializers/wrap_parameters.rb +0 -14
  40. data/test/dummy_app/config/locales/en.yml +0 -5
  41. data/test/dummy_app/config/routes.rb +0 -9
  42. data/test/dummy_app/config/secrets.yml +0 -22
  43. data/test/dummy_app/config.ru +0 -4
  44. data/test/dummy_app/db/schema.rb +0 -15
  45. data/test/dummy_app/db/test.sqlite3 +0 -0
  46. data/test/dummy_app/log/test.log +0 -484
  47. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/0o/0og-K-ORl6wO02dgU3z8beSXSGOCdnEFcX6KEtXqG2Q.cache +0 -1
  48. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/2V/2VONmeO4ClBgY1gjdZLYo9wQjDG9Ef9sAuwWVxceLEk.cache +0 -1
  49. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/34/34uQaon4nFa_kXcNF-1ac-QhL_HKtstSnb2pGjYCb6w.cache +0 -1
  50. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/3N/3NnKgR2TsTI1qCXKZpts0uJzp2dRJcoYp3nnFU6YE4o.cache +0 -2
  51. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/43/43Xh_xLNBt5kEi4-pWc5m0pFDLIhkNAxyiBf-3E2UJw.cache +0 -1
  52. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/4O/4O6Anm3R8aSIVfMhGtp5tZK3x17fcY1SbWoDN_6hb-o.cache +0 -2
  53. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/8x/8x5zY49XOU4gtdILE9T8l00lhs-lUJ6zzl5hyxjaFzw.cache +0 -0
  54. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/AT/ATEwOxnm0kBLQ6bdeFkXutl92AMg1dA40zmBqy2f2Ng.cache +0 -0
  55. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/Ag/AgeZ6zQVNy2sDfEUqjxoVLoCsGo6rA27SUQoJFjqCqY.cache +0 -1
  56. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/Dj/DjIeso8fWA-cG6Y9zSr3T0rPtpS6V73u3Q234QgSLa8.cache +0 -1
  57. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/Do/Do83AoOat5W-c1g7piDGy2GMmffsY6JY0Qfuh5PY3GM.cache +0 -2
  58. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/E_/E_ZbvXNGsLYdwZdD1F159gQCYVGJrWgaip0GlUx9B68.cache +0 -1
  59. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/LR/LRLaw7viwBb9Mi_VFZxGbKIooy8Fqf1aB_iOTETsMyc.cache +0 -3
  60. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/Lk/LkuzadDEF5r9a_QBFvWJ5krc5aerVbxs4zJ19iztB38.cache +0 -0
  61. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/Mj/MjwYGG9GkHD1fwwH2bg66EBYl3zCA_mqeDF9otey4-U.cache +0 -3
  62. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/Uc/UcQ6dMoNX10N68Sv8qxPf7kahPOJ5pqzYWkbjDKyF1k.cache +0 -1
  63. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/cp/cp36yIX2yPJBfhw6EA0u-BWnvFazmGC8zKxglna59TI.cache +0 -1
  64. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/dt/dteXKuRtjT5JiLleDPqnTNJFalNEbck9vA19hE6rGyw.cache +0 -1
  65. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/hy/hyxqCkBWzkpfHLCqW3YJeQq93KRADVcxEEMz0o0We_w.cache +0 -0
  66. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/k6/k6DfQWIBNnOJUNVvE59mXcoCzMB9D6i0p1WuJZGANoQ.cache +0 -1
  67. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/kR/kRjL0yRqyeZXZk93BSxxJULpCv-rJ3QvC23X4W94RNA.cache +0 -0
  68. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/pv/pv6tV3CDkIAmLXdU8EPLlNEkXAKJPufVD4VP30o4fWo.cache +0 -2
  69. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/vt/vtslB-h9sglaV55iVgO8l86UBTtzDnuA6qzCy-vzujk.cache +0 -0
  70. data/test/dummy_app/tmp/cache/assets/sprockets/v4.0.0/xD/xDLUWV68gWaS7IJWKWBAPzLcA0ALSjQHns0tsk0zY3s.cache +0 -0
  71. data/test/integration/prawn_rails_test.rb +0 -105
  72. data/test/prawn_rails_test.rb +0 -28
  73. data/test/test_helper.rb +0 -16
@@ -1,105 +0,0 @@
1
- ### FOR RAILS TESTS
2
-
3
- require 'test_helper'
4
- require 'pdf/reader'
5
-
6
- class NavigationTest < ActionDispatch::IntegrationTest
7
- fixtures :all
8
-
9
- def confirm_pdf_format(source)
10
- reader = PDF::Reader.new(StringIO.new(source))
11
- assert_not_nil(reader)
12
- assert_equal(1, reader.page_count)
13
- page_str = reader.pages[0].to_s
14
- assert page_str.include?('Hello World!')
15
- assert_not page_str.include?("<h1>Hello World!</h1>")
16
- end
17
-
18
- test "Registers :pdf mime type" do
19
- assert Mime::Type.lookup_by_extension(:pdf)
20
- end
21
-
22
- test "Registers :prawn template handler" do
23
- assert ActionView::Template::Handlers.extensions.include?(:prawn)
24
- end
25
-
26
- test "Renders html action" do
27
- get '/reports/sample'
28
- assert_response :success
29
- assert_match("<h1>Hello World!</h1>", @response.body)
30
- end
31
-
32
- test "Renders pdf to string" do
33
- pdf_str = ApplicationController.new.render_to_string("reports/sample.pdf", locals: {:@items => []})
34
-
35
- confirm_pdf_format(pdf_str)
36
- end
37
-
38
- test "Renders sample pdf action" do
39
- get '/reports/sample', params: {format: :pdf}
40
- assert_response :success
41
-
42
- confirm_pdf_format(@response.body)
43
- end
44
-
45
- test "Renders table pdf action using auto-required plugin Prawn-Table" do
46
- get '/reports/table', params: {format: :pdf}
47
- assert_response :success
48
-
49
- reader = PDF::Reader.new(StringIO.new(@response.body))
50
- assert_not_nil(reader)
51
-
52
- assert_equal(1, reader.page_count)
53
-
54
- page_str = reader.pages[0].to_s
55
-
56
- assert_equal(page_str, "1 2 3\n\n4 5 6\n\n7 8 9")
57
- end
58
-
59
- test "Sets file name from '@filename' when present" do
60
- get '/reports/ivar_filename.pdf'
61
-
62
- disposition_header = @response.headers["Content-Disposition"]
63
- assert disposition_header.include?("attachment")
64
- assert disposition_header.include?("ivar-filename.pdf")
65
- end
66
-
67
- test "Maintains existing 'Content-Disposition' header" do
68
- get '/reports/custom_headers.pdf'
69
-
70
- disposition_header = @response.headers["Content-Disposition"]
71
- assert disposition_header.include?("attachment")
72
- assert disposition_header.include?("custom-headers.pdf")
73
- end
74
-
75
- test "Respects the 'filename' option alone" do
76
- get '/reports/custom_filename.pdf'
77
-
78
- disposition_header = @response.headers["Content-Disposition"]
79
- assert disposition_header.include?("inline")
80
- assert disposition_header.include?("from-options.pdf")
81
- end
82
-
83
- test "Respects the 'disposition' option alone" do
84
- get '/reports/custom_disposition.pdf'
85
-
86
- disposition_header = @response.headers["Content-Disposition"]
87
- assert disposition_header.include?("attachment")
88
- assert_not disposition_header.include?("filename")
89
- end
90
-
91
- test "Respects both options on 'prawn-document' together" do
92
- get '/reports/custom.pdf'
93
-
94
- disposition_header = @response.headers["Content-Disposition"]
95
- assert disposition_header.include?("attachment")
96
- assert disposition_header.include?("from-options.pdf")
97
- end
98
-
99
- test "render_to_string in mailer" do
100
- mail = ReportsMailer.send_report
101
- assert_equal(1, mail.attachments.size)
102
-
103
- confirm_pdf_format(mail.attachments["report.pdf"].body.raw_source)
104
- end
105
- end
@@ -1,28 +0,0 @@
1
- ### FOR GENERIC NON-RAILS TESTS
2
-
3
- require 'test_helper'
4
- require 'pdf/reader'
5
-
6
- class PrawnRailsTest < ActiveSupport::TestCase
7
- include PrawnRails::RailsHelper
8
-
9
- test "text can take non strings" do
10
- output = prawn_document do |pdf|
11
- pdf.text "Number:"
12
- pdf.text 10
13
- end
14
-
15
- reader = PDF::Reader.new(StringIO.new(output))
16
- assert_not_nil(reader)
17
-
18
- page = reader.page(1).to_s
19
- assert page.include?("Number:\n10")
20
- end
21
-
22
- test "matches .PDF extension regardless of case" do
23
- ["pDf", "pdf", "PDF"].each do |ext|
24
- @filename = "test.#{ext}"
25
- assert_equal get_metadata[:info][:Title], "test"
26
- end
27
- end
28
- end
data/test/test_helper.rb DELETED
@@ -1,16 +0,0 @@
1
- ENV["RAILS_ENV"] = "test"
2
-
3
- begin
4
- require 'warning'
5
-
6
- Warning.ignore(
7
- %r{mail/parsers/address_lists_parser}, ### Hide mail gem warnings
8
- )
9
- rescue LoadError
10
- # Do nothing
11
- end
12
-
13
- require File.expand_path("../dummy_app/config/environment.rb", __FILE__)
14
- require "rails/test_help"
15
-
16
- Rails.backtrace_cleaner.remove_silencers!