Merge pull request #51121 from jamiemccarthy/jm-fix-allow-browser-versions
Fix AllowBrowser versions
This commit is contained in:
commit
3ccca0cc54
@ -20,7 +20,7 @@ module ClassMethods
|
||||
# In addition to specifically named browser versions, you can also pass
|
||||
# `:modern` as the set to restrict support to browsers natively supporting webp
|
||||
# images, web push, badges, import maps, CSS nesting, and CSS :has. This
|
||||
# includes Safari 17.2+, Chrome 119+, Firefox 121+, Opera 104+.
|
||||
# includes Safari 17.2+, Chrome 120+, Firefox 121+, Opera 106+.
|
||||
#
|
||||
# You can use https://caniuse.com to check for browser versions supporting the
|
||||
# features you use.
|
||||
@ -31,7 +31,7 @@ module ClassMethods
|
||||
# Examples:
|
||||
#
|
||||
# class ApplicationController < ActionController::Base
|
||||
# # Allow only browsers natively supporting webp images, web push, badges, import maps, CSS nesting + :has
|
||||
# # Allow only browsers natively supporting webp images, web push, badges, import maps, CSS nesting, and CSS :has
|
||||
# allow_browser versions: :modern
|
||||
# end
|
||||
#
|
||||
@ -62,7 +62,7 @@ def allow_browser(versions:, block:)
|
||||
|
||||
class BrowserBlocker
|
||||
SETS = {
|
||||
modern: { safari: 17.2, chrome: 119, firefox: 121, opera: 104, ie: false }
|
||||
modern: { safari: 17.2, chrome: 120, firefox: 121, opera: 106, ie: false }
|
||||
}
|
||||
|
||||
attr_reader :request, :versions
|
||||
|
@ -3,7 +3,7 @@
|
||||
require "abstract_unit"
|
||||
|
||||
class AllowBrowserController < ActionController::Base
|
||||
allow_browser versions: { safari: "16.4", chrome: "119", firefox: "123", opera: "104", ie: false }, block: -> { head :upgrade_required }, only: :hello
|
||||
allow_browser versions: { safari: "16.4", chrome: "119", firefox: "123", opera: "106", ie: false }, block: -> { head :upgrade_required }, only: :hello
|
||||
def hello
|
||||
head :ok
|
||||
end
|
||||
@ -22,7 +22,7 @@ class AllowBrowserTest < ActionController::TestCase
|
||||
SAFARI_17_2_0 = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2.0 Safari/605.1.15"
|
||||
FIREFOX_114 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:109.0) Gecko/20100101 Firefox/114.0"
|
||||
IE_11 = "Mozilla/5.0 (Windows NT 10.0; WOW64; Trident/7.0; rv:11.0) like Gecko"
|
||||
OPERA_104 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.69 Safari/537.36 OPR/104.0.4638.54"
|
||||
OPERA_106 = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 OPR/106.0.0.0"
|
||||
|
||||
test "blocked browser below version limit" do
|
||||
get_with_agent :hello, FIREFOX_114
|
||||
@ -41,7 +41,7 @@ class AllowBrowserTest < ActionController::TestCase
|
||||
get_with_agent :hello, CHROME_120
|
||||
assert_response :ok
|
||||
|
||||
get_with_agent :hello, OPERA_104
|
||||
get_with_agent :hello, OPERA_106
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
@ -55,7 +55,7 @@ class AllowBrowserTest < ActionController::TestCase
|
||||
get_with_agent :modern, CHROME_120
|
||||
assert_response :ok
|
||||
|
||||
get_with_agent :modern, OPERA_104
|
||||
get_with_agent :modern, OPERA_106
|
||||
assert_response :ok
|
||||
end
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user