Skip to content

Commit

Permalink
1138 app and specs working under Ruby 3.0.6
Browse files Browse the repository at this point in the history
  • Loading branch information
ferrisoxide committed Jul 28, 2023
1 parent 6eb1726 commit 9ad2907
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 21 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,5 @@ Design

.passenger
.vagrant
storage/
storage/
.byebug_history
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.5
3.0.6
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -529,6 +530,7 @@ DEPENDENCIES
tzinfo-data
uglifier
webdrivers
webrick
will_paginate
zeus

Expand Down
12 changes: 2 additions & 10 deletions lib/fat_free_crm/errors.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion lib/fat_free_crm/i18n.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 7 additions & 7 deletions spec/features/support/browser.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 24 additions & 0 deletions spec/lib/fat_free_crm/i18n_spec.rb
Original file line number Diff line number Diff line change
@@ -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_controler) { TestController.new }

it 'should translate hash arguments' do
expect(test_controler.t(:not_showing_hidden_entities, entity: entity_string, count: hidden_count))
.to eq("Not showing 10 hidden entities.")
end
end

0 comments on commit 9ad2907

Please sign in to comment.