File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
actionpack/lib/action_controller/metal
railties/test/application Expand file tree Collapse file tree 2 files changed +18
-1
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ module EtagWithFlash
12
12
include ActionController ::ConditionalGet
13
13
14
14
included do
15
- etag { flash unless flash . empty? }
15
+ etag { flash if request . respond_to? ( :flash ) && ! flash . empty? }
16
16
end
17
17
end
18
18
end
Original file line number Diff line number Diff line change @@ -632,6 +632,23 @@ def index
632
632
assert last_response . ok?
633
633
end
634
634
635
+ test "EtagWithFlash module doesn't break for API apps" do
636
+ make_basic_app do |application |
637
+ application . config . api_only = true
638
+ end
639
+
640
+ class ::OmgController < ActionController ::Base
641
+ def index
642
+ stale? ( weak_etag : "something" )
643
+ render plain : "else"
644
+ end
645
+ end
646
+
647
+ get "/"
648
+
649
+ assert last_response . ok?
650
+ end
651
+
635
652
test "Use key_generator when secret_key_base is set" do
636
653
make_basic_app do |application |
637
654
application . secrets . secret_key_base = "b3c631c314c0bbca50c1b2843150fe33"
You can’t perform that action at this time.
0 commit comments