diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 88d2a343a..870441667 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -2,7 +2,6 @@ class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception - before_action :check_browser before_action :load_navbar_left_pannel_partial_url before_action :set_raven_context before_action :authorize_request_for_profiler @@ -26,10 +25,6 @@ class ApplicationController < ActionController::Base {} end - def check_browser - BROWSER.value = BrowserService.get_browser(request) - end - def load_navbar_left_pannel_partial_url controller = request.controller_class method = params[:action] diff --git a/app/services/browser_service.rb b/app/services/browser_service.rb deleted file mode 100644 index 0163bbe6e..000000000 --- a/app/services/browser_service.rb +++ /dev/null @@ -1,17 +0,0 @@ -class BrowserService - def self.get_browser request - BROWSER.value = Browser.new(request.user_agent) - end - - def self.recommended_browser? - browser = BROWSER.value - - return false if browser.chrome? && browser.version.to_i < 40 - return false if browser.ie?(["<10"]) - return false if browser.firefox? && browser.version.to_i < 45 - return false if browser.opera? && browser.version.to_i < 19 - return false if browser.safari? && browser.version.to_i < 8 - - true - end -end diff --git a/app/views/layouts/_support_navigator_banner.html.haml b/app/views/layouts/_support_navigator_banner.html.haml index dcd937860..5f6cf628e 100644 --- a/app/views/layouts/_support_navigator_banner.html.haml +++ b/app/views/layouts/_support_navigator_banner.html.haml @@ -1,7 +1,7 @@ -- if !BrowserService.recommended_browser? +- if !browser.modern? #support-navigator-banner.row .col-xs-12 - = BROWSER.value.name - = BROWSER.value.version + = browser.name + = browser.version \- Attention, votre navigateur n'est pas recommandé pour la navigation sur ce site internet. Aucun support ne pourra vous être prodigué en cas de dysfonctionnement. diff --git a/config/initializers/browser.rb b/config/initializers/browser.rb index 950d9536c..647ce8a39 100644 --- a/config/initializers/browser.rb +++ b/config/initializers/browser.rb @@ -1,3 +1,7 @@ -BROWSER = Hashie::Mash.new ({ - value: nil -}) +Browser.modern_rules.clear +Browser.modern_rules << -> b { b.chrome? && b.version.to_i >= 40 } +Browser.modern_rules << -> b { b.ie?([">=10"]) } +Browser.modern_rules << -> b { b.edge? } +Browser.modern_rules << -> b { b.firefox? && b.version.to_i >= 45 } +Browser.modern_rules << -> b { b.opera? && b.version.to_i >= 19 } +Browser.modern_rules << -> b { b.safari? && b.version.to_i >= 8 } diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 8ab5e7d15..266047f62 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -69,7 +69,6 @@ end DatabaseCleaner.strategy = :transaction SIADETOKEN = :valid_token if !defined? SIADETOKEN -BROWSER.value = Browser.new('Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; Win64; x64; Trident/6.0)') include Warden::Test::Helpers