Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix method name when checking if controllers respond to after_action #663

Merged
merged 1 commit into from
Jun 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/wicked_pdf/pdf_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ def self.included(base)
base.class_eval do
alias_method_chain :render, :wicked_pdf
alias_method_chain :render_to_string, :wicked_pdf
if respond_to?(:after_action?)
if respond_to?(:after_action)
after_action :clean_temp_files
else
after_filter :clean_temp_files
Expand Down
10 changes: 10 additions & 0 deletions test/functional/pdf_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ class Base
def render_to_string(opts = {})
opts.to_s
end

def self.alias_method_chain(_, _); end
end
end

Expand Down Expand Up @@ -83,4 +85,12 @@ def teardown
end
end
end

test 'should call after_action instead of after_filter when able' do
ActionController::Base.expects(:after_filter).with(:clean_temp_files).never
ActionController::Base.expects(:after_action).with(:clean_temp_files).once
ActionController::Base.class_eval do
include ::WickedPdf::PdfHelper
end
end
end