Skip to content
This repository was archived by the owner on Mar 13, 2024. It is now read-only.

Commit 5822c72

Browse files
committed
Fix Rails 6 Deprecation
1 parent 4c593d1 commit 5822c72

21 files changed

+61
-36
lines changed

.travis.yml

+10-7
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,24 @@
1-
sudo: false
21
language: ruby
32
script: bundle exec rspec spec
3+
44
rvm:
55
- 1.9.3
66
- 2.0.0
77
- 2.1.0
88
- 2.2.0
99
- jruby-19mode
10-
gemfile:
11-
- spec/gemfiles/Gemfile.rails-3.2.x
12-
- spec/gemfiles/Gemfile.rails-4.0.x
13-
- spec/gemfiles/Gemfile.rails-4.1.x
10+
11+
gemfile:
1412
- spec/gemfiles/Gemfile.rails-4.2.x
13+
- spec/gemfiles/Gemfile.rails-5.0.x
14+
- spec/gemfiles/Gemfile.rails-6.0.x
15+
1516
matrix:
1617
exclude:
17-
- rvm: 1.9.3
18-
gemfile: spec/gemfiles/rails-4.1.x.gemfile
1918
- rvm: 1.9.3
2019
gemfile: spec/gemfiles/rails-4.2.x.gemfile
20+
- rvm: 1.9.3
21+
gemfile: spec/gemfiles/rails-5.0.x.gemfile
22+
- rvm: 1.9.3
23+
gemfile: spec/gemfiles/rails-6.0.x.gemfile
2124
fast_finish: true

Gemfile

-6
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,2 @@
11
source "https://rubygems.org"
22
gemspec
3-
4-
gem "guard"
5-
gem "guard-rspec"
6-
7-
gem "rails", "5.2.1"
8-
gem "test-unit"

lib/prawnto/compile_support.rb

+1-4
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ def set_cache_control
6565
end
6666

6767
def set_content_type
68-
@controller.response.content_type ||= Mime[:pdf]
68+
@controller.response.content_type = Mime[:pdf]
6969
end
7070

7171
def set_disposition
@@ -76,6 +76,3 @@ def set_disposition
7676

7777
end
7878
end
79-
80-
81-

lib/prawnto/template_handlers/base.rb

+4-5
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,13 @@
33
module Prawnto
44
module TemplateHandlers
55
class Base
6-
def self.call(template)
7-
check_for_pdf_redefine(template.source)
6+
def self.call(template, source = nil)
7+
source ||= template.source
8+
check_for_pdf_redefine(source)
89

910
"_prawnto_compile_setup;" +
1011
"renderer = Prawnto::TemplateHandlers::Renderer.new(self);"+
11-
"renderer.to_pdf(self) do; #{template.source}\nend;"
12+
"renderer.to_pdf(self) do; #{source}\nend;"
1213
end
1314

1415
private
@@ -21,5 +22,3 @@ def self.check_for_pdf_redefine(template_source)
2122
end
2223
end
2324
end
24-
25-

prawnto.gemspec

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Gem::Specification.new do |s|
22
s.name = "prawnto_2"
3-
s.version = '0.3.0'
3+
s.version = '0.3.1'
44
s.author = ["Jobber", "Forrest Zeisler", "Nathan Youngman"]
55
s.email = ["[email protected]"]
66
s.date = Time.now.utc.strftime("%Y-%m-%d")
@@ -19,6 +19,5 @@ Gem::Specification.new do |s|
1919
s.files = Dir["{app,config,db,lib}/**/*"] + ["MIT-LICENSE", "Rakefile", "README.rdoc"]
2020
s.test_files = Dir["test/**/*"]
2121

22-
s.has_rdoc = true
2322
s.extra_rdoc_files = ["README.rdoc"]
2423
end
1.15 KB
Binary file not shown.

spec/assets/2.5/dsl_render-2.3.0.pdf

1.17 KB
Binary file not shown.

spec/assets/2.5/fancy_name-2.3.0.pdf

1.15 KB
Binary file not shown.
1 KB
Binary file not shown.
1.06 KB
Binary file not shown.
Binary file not shown.

spec/controllers/test_controller_spec.rb

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
describe "simple" do
77
it "returns correct PDF" do
88
get :default_render, :format => :pdf
9-
expect(response).to be_success
9+
expect(response).to be_successful
1010

1111
asset_binary = File.open(asset_path("default_render")).read.bytes.to_a
1212
body_binary = response.body.bytes.to_a
@@ -20,7 +20,7 @@
2020

2121
it "should render items in a block passed to a helper" do
2222
get :yield_block_in_helper_test, :format => :pdf
23-
expect(response).to be_success
23+
expect(response).to be_successful
2424

2525
asset_binary = File.open(asset_path("yield_block_in_helper_test")).read.bytes.to_a
2626
body_binary = response.body.bytes.to_a
@@ -32,7 +32,7 @@
3232
describe "dsl" do
3333
it "returns correct PDF" do
3434
get :dsl_render, :format => :pdf
35-
expect(response).to be_success
35+
expect(response).to be_successful
3636

3737
asset_binary = File.open(asset_path("dsl_render")).read.bytes.to_a
3838
body_binary = response.body.bytes.to_a
@@ -43,7 +43,7 @@
4343
describe "partials" do
4444
it "renders partials" do
4545
get :partial_render, :format => :pdf
46-
expect(response).to be_success
46+
expect(response).to be_successful
4747

4848
asset_binary = File.open(asset_path("partial_render")).read.bytes.to_a
4949
body_binary = response.body.bytes.to_a
@@ -54,7 +54,7 @@
5454
describe "complex headers" do
5555
it "should return a file with a specified filename" do
5656
get :filename_test, :format => :pdf
57-
expect(response).to be_success
57+
expect(response).to be_successful
5858

5959
expect(response.header["Content-Disposition"]).to eq("attachment;filename=\"fancy_name.pdf\"")
6060
end
+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
//= link application.css.scss
2+
//= link application.js

spec/dummy/config/environments/development.rb

+3
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@
2727

2828
# Expands the lines which load the assets
2929
config.assets.debug = true
30+
31+
# Do not eager load code on boot.
32+
config.eager_load = false
3033
end

spec/dummy/config/environments/production.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
config.action_controller.perform_caching = true
1010

1111
# Disable Rails's static asset server (Apache or nginx will already do this)
12-
config.serve_static_assets = false
12+
config.serve_static_files = false
1313

1414
# Compress JavaScripts and CSS
1515
config.assets.compress = true
@@ -57,4 +57,7 @@
5757

5858
# Send deprecation notices to registered listeners
5959
config.active_support.deprecation = :notify
60+
61+
# Eager load code on boot.
62+
config.eager_load = true
6063
end

spec/dummy/config/environments/test.rb

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
config.cache_classes = true
99

1010
# Configure static asset server for tests with Cache-Control for performance
11-
config.serve_static_assets = true
11+
config.serve_static_files = true
1212
config.static_cache_control = "public, max-age=3600"
1313

1414
# Log error messages when you accidentally call methods on nil
@@ -36,4 +36,12 @@
3636

3737
# Print deprecation notices to the stderr
3838
config.active_support.deprecation = :stderr
39+
40+
# Use sort order with tests
41+
config.active_support.test_order = :sorted
42+
43+
# Do not eager load code on boot.
44+
config.eager_load = false
45+
46+
3947
end

spec/dummy/config/initializers/secret_token.rb

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,7 @@
44
# If you change this key, all old signed cookies will become invalid!
55
# Make sure the secret is at least 30 characters and all random,
66
# no regular words or you'll be exposed to dictionary attacks.
7-
Dummy::Application.config.secret_token = '8f4cbaa2b5177e95c5ec90b258ddd53b6c7efdcb4fa0a5bb098f5fd9d034b82ad56889231e2c2cdba5dc821042bdc4f9919cb94f1522b49f4e1a0a08d6b2d166'
7+
if Rails::VERSION::MAJOR < 5
8+
Dummy::Application.config.secret_token = '8f4cbaa2b5177e95c5ec90b258ddd53b6c7efdcb4fa0a5bb098f5fd9d034b82ad56889231e2c2cdba5dc821042bdc4f9919cb94f1522b49f4e1a0a08d6b2d166'
9+
end
10+
Dummy::Application.config.secret_key_base = '6e645b1c4eb2351e8e90ae0194ad60f6f3c6e2e77e92c352e87e39e075e2ce0e22ef35fb813681ab23fb735ea54046c613beb03885946167159e4370c7afe3a4'

spec/gemfiles/Gemfile.rails-4.2.x

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
source "https://rubygems.org"
22
gemspec :path => "./../.."
33

4+
gem "guard"
5+
gem "guard-rspec"
6+
47
gem "rails", "~> 4.2.0"
58
gem "test-unit" # for Ruby 2.2.0

spec/gemfiles/Gemfile.rails-5.0.x

+3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
source "https://rubygems.org"
22
gemspec :path => "./../.."
33

4+
gem "guard"
5+
gem "guard-rspec"
6+
47
gem "rails", "~> 5.2.1"
58
gem "test-unit" # for Ruby 2.2.0

spec/gemfiles/Gemfile.rails-6.0.x

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
source "https://rubygems.org"
2+
gemspec :path => "./../.."
3+
4+
gem "guard"
5+
gem "guard-rspec"
6+
7+
gem "rails", "~> 6.0.3.3"
8+
gem "test-unit" # for Ruby 2.2.0

spec/integrations/pdf_emailer_spec.rb

+4-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
describe PdfEmailer do
44
describe "email_with_attachment" do
55
before(:all) do
6-
@email = PdfEmailer.email_with_attachment.deliver
6+
@email = PdfEmailer.email_with_attachment.deliver_now
77
end
8-
8+
99
it "should have the plain text on the body" do
1010
expect(@email.encoded).to include "text\/plain"
1111
expect(@email.encoded).to include "Please see attached PDF"
1212
end
13-
13+
1414
it "should have the PDF attached" do
1515
expect(@email.encoded).to include "application\/pdf"
1616
expect(@email.encoded).to include "Content-Disposition: attachment;"
1717
expect(@email.encoded).to include "filename=hello_world.pdf"
1818
end
19-
19+
2020
end
2121
end

0 commit comments

Comments
 (0)