From f1b31c37757a6756ff43aa6ebeccc501f7c156c4 Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 6 Sep 2023 14:16:25 +0300 Subject: [PATCH 1/2] added localize parameters to url --- app/controllers/application_controller.rb | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8476c2166..cdad32ffb 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -8,12 +8,16 @@ class ApplicationController < ActionController::Base policy.style_src :self, 'www.gstatic.com', :unsafe_inline end - rescue_from CanCan::AccessDenied do |exception| + rescue_from CanCan::AccessDenied do |_exception| flash[:alert] = I18n.t('unauthorized.message') redirect_to root_url end def set_locale + if params[:localize].present? && I18n.available_locales.include?(params[:localize].to_sym) + cookies[:locale] = params[:localize] + end + I18n.locale = current_user&.locale || cookies[:locale] || I18n.default_locale @pagy_locale = I18n.locale.to_s end From faeba6ad4f9815266d4749649ec4c659cec2321d Mon Sep 17 00:00:00 2001 From: Oleg Hasjanov Date: Wed, 6 Sep 2023 14:28:35 +0300 Subject: [PATCH 2/2] remove webdrvers --- Gemfile | 2 +- Gemfile.lock | 6 +----- test/application_system_test_case.rb | 5 ----- 3 files changed, 2 insertions(+), 11 deletions(-) diff --git a/Gemfile b/Gemfile index 4891709bb..d831c19c3 100644 --- a/Gemfile +++ b/Gemfile @@ -60,7 +60,7 @@ group :test do gem 'capybara', '>= 2.15' gem 'simplecov', '~> 0.10', '< 0.18', require: false gem 'spy' - gem 'webdrivers' + gem 'selenium-webdriver' gem 'webmock' end diff --git a/Gemfile.lock b/Gemfile.lock index c74240f2e..ca7ab20ec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -408,10 +408,6 @@ GEM activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webdrivers (5.2.0) - nokogiri (~> 1.6) - rubyzip (>= 1.3.0) - selenium-webdriver (~> 4.0) webfinger (1.2.0) activesupport httpclient (>= 2.4) @@ -479,6 +475,7 @@ DEPENDENCIES rubocop-performance ruby-openai scenic + selenium-webdriver simplecov (~> 0.10, < 0.18) simpleidn skylight @@ -486,7 +483,6 @@ DEPENDENCIES spy turbo-rails web-console (>= 3.3.0) - webdrivers webmock webpacker (~> 6.0.0.rc.5) webpush diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 634165538..415f58765 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -7,9 +7,6 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase include SemanticUiHelper - # 115.0.5790 - Webdrivers::Chromedriver.required_version = '114.0.5735.90' - Capybara.register_driver(:headless_chrome) do |app| options = ::Selenium::WebDriver::Chrome::Options.new options.add_argument('--headless') @@ -20,8 +17,6 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end - Webdrivers::Chromedriver.required_version = '114.0.5735.90' - driven_by :headless_chrome Capybara.server = :puma, { Silent: true }