Skip to content

Commit 097705a

Browse files
committed
[LOCATION] Request eu checks if helper method defined
1 parent 7adca58 commit 097705a

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

lib/action_pack/cloudfront/location_headers.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff 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

lib/action_pack/cloudfront/railtie.rb

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class Railtie < ::Rails::Railtie
1919
config.to_prepare do
2020
::ApplicationController.send :include, ActionPack::Cloudfront::LocationHeaders
2121
end
22-
2322
end
2423
end
2524
end
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
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

0 commit comments

Comments
 (0)