diff --git a/.gitignore b/.gitignore index 065e9487ff..6ba0b9feb7 100644 --- a/.gitignore +++ b/.gitignore @@ -28,4 +28,5 @@ Design .passenger .vagrant -storage/ \ No newline at end of file +storage/ +.byebug_history diff --git a/.ruby-version b/.ruby-version index a603bb50a2..818bd47abf 100644 --- a/.ruby-version +++ b/.ruby-version @@ -1 +1 @@ -2.7.5 +3.0.6 diff --git a/Gemfile b/Gemfile index ee15d9ed13..2f687f717b 100644 --- a/Gemfile +++ b/Gemfile @@ -79,6 +79,7 @@ group :test do gem 'zeus', platform: :ruby unless ENV["CI"] gem 'timecop' gem 'sqlite3', '~> 1.4.0' + gem 'webrick' end group :heroku do diff --git a/Gemfile.lock b/Gemfile.lock index b3b6b721e0..f945096f3f 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -159,7 +159,7 @@ GEM devise-i18n (1.11.0) devise (>= 4.9.0) diff-lcs (1.5.0) - dynamic_form (1.1.4) + dynamic_form (1.2.0) email_reply_parser_ffcrm (0.5.0) erubi (1.12.0) execjs (2.8.1) @@ -439,6 +439,7 @@ GEM nokogiri (~> 1.6) rubyzip (>= 1.3.0) selenium-webdriver (~> 4.0) + webrick (1.8.1) websocket (1.2.9) websocket-driver (0.7.5) websocket-extensions (>= 0.1.0) @@ -529,6 +530,7 @@ DEPENDENCIES tzinfo-data uglifier webdrivers + webrick will_paginate zeus diff --git a/lib/fat_free_crm/errors.rb b/lib/fat_free_crm/errors.rb index e7e3fb52e6..39fffa279a 100644 --- a/lib/fat_free_crm/errors.rb +++ b/lib/fat_free_crm/errors.rb @@ -21,16 +21,8 @@ def self.included(base) end end - def each_with_explicit_error - attribute_names.each do |attribute| - self[attribute].each do |error| - if error.start_with?('^') - yield :base, error[1..-1] # Drop the attribute. - else - yield attribute, error # This is default Rails3 behavior. - end - end - end + def each_with_explicit_error(&block) + @errors.each(&block) end end end diff --git a/lib/fat_free_crm/i18n.rb b/lib/fat_free_crm/i18n.rb index 3261fe9e61..f3cd817d89 100644 --- a/lib/fat_free_crm/i18n.rb +++ b/lib/fat_free_crm/i18n.rb @@ -14,7 +14,7 @@ def t(*args) if args.size == 1 super(args.first, default: args.first.to_s) elsif args.second.is_a?(Hash) - super(*args) + super(args.first, **args.second) elsif args.second.is_a?(Integer) super(args.first, count: args.second) else diff --git a/spec/features/support/browser.rb b/spec/features/support/browser.rb index e5235b4c7b..cbf9c4681d 100644 --- a/spec/features/support/browser.rb +++ b/spec/features/support/browser.rb @@ -11,18 +11,18 @@ if ENV['BROWSER'] == 'chrome' Capybara.register_driver :selenium do |app| - capabilities = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w[no-sandbox headless disable-gpu] }) - Capybara::Selenium::Driver.new(app, browser: :chrome, desired_capabilities: capabilities) + options = Selenium::WebDriver::Remote::Capabilities.chrome(chromeOptions: { args: %w[no-sandbox headless disable-gpu] }) + Capybara::Selenium::Driver.new(app, browser: :chrome, options: options) end else # For local testing in an environment with a display or remote X server configured # such as WSL2, use NO_HEADLESS=1 bundle exec rspec spec/features # - # For modern firefox, use MARIONETTE=1 bundle exec rspec spec/features + # NB the marionette setting is deprecated. For modern firefox, install the geckodriver. Capybara.register_driver :selenium do |app| - options = Selenium::WebDriver::Firefox::Options.new - options.args << '--headless' unless ENV['NO_HEADLESS'].present? - capabilities = Selenium::WebDriver::Remote::Capabilities.firefox(marionette: ENV['MARIONETTE'].present?) - Capybara::Selenium::Driver.new(app, browser: :firefox, options: options, desired_capabilities: capabilities) + options = Selenium::WebDriver::Options.firefox + options.add_argument('-headless') unless ENV['NO_HEADLESS'].present? + + Capybara::Selenium::Driver.new(app, browser: :firefox, options: options) end end diff --git a/spec/lib/fat_free_crm/i18n_spec.rb b/spec/lib/fat_free_crm/i18n_spec.rb new file mode 100644 index 0000000000..2a1c32745c --- /dev/null +++ b/spec/lib/fat_free_crm/i18n_spec.rb @@ -0,0 +1,24 @@ +# frozen_string_literal: true + +# Copyright (c) 2008-2013 Michael Dvorkin and contributors. +# +# Fat Free CRM is freely distributable under the terms of MIT license. +# See MIT-LICENSE file or http://www.opensource.org/licenses/mit-license.php +#------------------------------------------------------------------------------ +require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper') + +describe 'I18n.t()' do + + class TestController < ActionController::Base + include FatFreeCRM::I18n + end + + let(:entity_string) { 'entities' } + let(:hidden_count) { 10 } + let(:test_controller) { TestController.new } + + it 'should translate hash arguments' do + expect(test_controller.t(:not_showing_hidden_entities, entity: entity_string, count: hidden_count)) + .to eq("Not showing 10 hidden entities.") + end +end