File tree Expand file tree Collapse file tree 3 files changed +23
-3
lines changed
lib/action_pack/cloudfront
test/actionpack/cloudfront Expand file tree Collapse file tree 3 files changed +23
-3
lines changed Original file line number Diff line number Diff line change @@ -9,7 +9,9 @@ module LocationHeaders
99 |RS|SK|SI|ES|SE|CH|UA|GB|VA|RS)$/ix
1010
1111 included do
12- helper_method :request_eu?
12+ if respond_to? ( :helper_method )
13+ helper_method :request_eu?
14+ end
1315 end
1416
1517 private
Original file line number Diff line number Diff line change @@ -6,6 +6,7 @@ class Railtie < ::Rails::Railtie
66
77 config . action_pack_cloudfront = ActiveSupport ::OrderedOptions . new
88 config . action_pack_cloudfront . load_proxies = !::Rails . env . test? && !::Rails . env . development?
9+ config . action_pack_cloudfront . include_location_headers = true
910
1011 config . before_initialize do |app |
1112 if app . config . action_pack_cloudfront . load_proxies
@@ -17,9 +18,10 @@ class Railtie < ::Rails::Railtie
1718 end
1819
1920 config . to_prepare do
20- ::ApplicationController . send :include , ActionPack ::Cloudfront ::LocationHeaders
21+ if app . config . action_pack_cloudfront . include_location_headers
22+ ::ApplicationController . send :include , ActionPack ::Cloudfront ::LocationHeaders
23+ end
2124 end
22-
2325 end
2426 end
2527end
Original file line number Diff line number Diff line change 1+ require 'test_helper'
2+
3+ class LocationHeadersTest < ActiveSupport ::TestCase
4+ class ApplicationController < ActionController ::Base
5+ include ActionPack ::Cloudfront ::LocationHeaders
6+ end
7+
8+ class ApiController < ActionController ::API
9+ include ActionPack ::Cloudfront ::LocationHeaders
10+ end
11+
12+ test '#request_eu? - includes when has helper method' do
13+ assert_includes ApplicationController . _helper_methods , :request_eu?
14+ assert_nil ApiController . try ( :_helper_methods )
15+ end
16+ end
You can’t perform that action at this time.
0 commit comments