Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

App and specs working under Ruby 3.1.4 #1138 #1139

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/brakeman-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:

- name: Setup Brakeman
env:
BRAKEMAN_VERSION: '4.10' # SARIF support is provided in Brakeman version 4.10+
BRAKEMAN_VERSION: '6.0.1' # SARIF support is provided in Brakeman version 4.10+
run: |
gem install brakeman --version $BRAKEMAN_VERSION

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ruby.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
ruby-version: ['2.7'] # , '2.7', '3.0'
ruby-version: ['3.1'] # , '2.7', '3.0'

steps:
- uses: actions/checkout@v3
Expand Down
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 .rubocop.yml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
inherit_from: .rubocop_todo.yml

AllCops:
TargetRubyVersion: 2.7
TargetRubyVersion: 3.1

Bundler/OrderedGems:
Enabled: false
Expand Down
2 changes: 1 addition & 1 deletion .ruby-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.7.5
3.1.4
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
# docker-compose up
# docker-compose exec web bundle exec rake db:create db:schema:load ffcrm:demo:load

FROM ruby:2.7
FROM ruby:3.1

LABEL author="Steve Kenworthy"

Expand Down
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
22 changes: 12 additions & 10 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ GEM
autoprefixer-rails (>= 9.1.0)
popper_js (>= 2.9.2, < 3)
sassc-rails (>= 2.0.0)
brakeman (5.4.1)
brakeman (6.0.1)
builder (3.2.4)
byebug (11.1.3)
cancancan (3.5.0)
Expand Down 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 @@ -231,7 +231,7 @@ GEM
mini_mime (1.1.2)
mini_racer (0.6.4)
libv8-node (~> 16.19.0.0)
minitest (5.18.1)
minitest (5.19.0)
msgpack (1.6.0)
nenv (0.3.0)
net-imap (0.3.6)
Expand All @@ -253,9 +253,9 @@ GEM
nenv (~> 0.1)
shellany (~> 0.0)
orm_adapter (0.5.0)
paper_trail (12.0.0)
activerecord (>= 5.2)
request_store (~> 1.1)
paper_trail (15.0.0)
activerecord (>= 6.1)
request_store (~> 1.4)
parallel (1.23.0)
parser (3.2.2.3)
ast (~> 2.4.1)
Expand All @@ -275,7 +275,7 @@ GEM
puma (6.3.0)
nio4r (~> 2.0)
racc (1.7.1)
rack (2.2.7)
rack (2.2.8)
rack-test (2.1.0)
rack (>= 1.3)
rails (6.1.7.4)
Expand Down Expand Up @@ -341,7 +341,7 @@ GEM
rb-inotify (0.10.1)
ffi (~> 1.0)
regexp_parser (2.8.1)
request_store (1.5.0)
request_store (1.5.1)
rack (>= 1.4)
responders (3.1.0)
actionpack (>= 5.2)
Expand Down Expand Up @@ -439,14 +439,15 @@ GEM
nokogiri (~> 1.6)
rubyzip (>= 1.3.0)
selenium-webdriver (~> 4.0, < 4.11)
webrick (1.8.1)
websocket (1.2.9)
websocket-driver (0.7.5)
websocket-extensions (>= 0.1.0)
websocket-extensions (0.1.5)
will_paginate (4.0.0)
xpath (3.2.0)
nokogiri (~> 1.8)
zeitwerk (2.6.8)
zeitwerk (2.6.11)
zeus (0.15.14)
method_source (>= 0.6.7)

Expand Down Expand Up @@ -494,7 +495,7 @@ DEPENDENCIES
mini_magick
mini_racer
nokogiri (>= 1.8.1)
paper_trail (~> 12.0.0)
paper_trail (~> 15.0.0)
pg
premailer
pry-rails
Expand Down Expand Up @@ -529,6 +530,7 @@ DEPENDENCIES
tzinfo-data
uglifier
webdrivers
webrick
will_paginate
zeus

Expand Down
12 changes: 12 additions & 0 deletions config/application.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,18 @@ class Application < Rails::Application

# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += %i[password encrypted_password password_salt password_confirmation]

# Enable support for loading via Psych, required by PaperTrail
config.active_record.use_yaml_unsafe_load = false
config.active_record.yaml_column_permitted_classes = [
::ActiveRecord::Type::Time::Value,
::ActiveSupport::TimeWithZone,
::ActiveSupport::TimeZone,
::BigDecimal,
::Date,
::Symbol,
::Time
]
end
end

Expand Down
4 changes: 2 additions & 2 deletions fat_free_crm.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Gem::Specification.new do |gem|
gem.email = ['mike@fatfreecrm.com', 'steveyken@gmail.com', 'daniel.oconnor@gmail.com']
gem.files = Dir["{app,config,db,lib,vendor,public,bin,log/script}/**/*", "MIT-LICENSE", "Rakefile", "README.md", "config.ru", "CHANGELOG.md", "CONTRIBUTING.md"]
gem.version = FatFreeCRM::VERSION::STRING
gem.required_ruby_version = '>= 2.7.0'
gem.required_ruby_version = '>= 3.1'
gem.license = 'MIT'

gem.add_dependency 'rails', '~> 6.1.0'
Expand All @@ -27,7 +27,7 @@ Gem::Specification.new do |gem|
gem.add_dependency 'select2-rails'
gem.add_dependency 'simple_form'
gem.add_dependency 'will_paginate'
gem.add_dependency 'paper_trail', '~> 12.0.0'
gem.add_dependency 'paper_trail', '~> 15.0.0'
gem.add_dependency 'devise', '~> 4.6'
gem.add_dependency 'devise-encryptable', '~> 0.2.0'
gem.add_dependency 'acts_as_commentable', '~> 6.0.0'
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)
Dismissed Show dismissed Hide dismissed
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)
Dismissed Show dismissed Hide dismissed
end
end
23 changes: 23 additions & 0 deletions spec/lib/fat_free_crm/i18n_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# 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')

class TestController < ActionController::Base
include FatFreeCRM::I18n
end

describe 'I18n.t()' do
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
17 changes: 17 additions & 0 deletions spec/models/polymorphic/version_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,23 @@
@version = Version.where(related_id: @item.id, related_type: @item.class.name, whodunnit: PaperTrail.request.whodunnit, event: 'create').first
expect(@version).not_to eq(nil)
end

# NOTE: This to ensure that the yaml_column_permitted_classes config option in
# application.rb is set correctly. If this test fails, then you need to add the
# class to the list of permitted classes.
it "should include version object changes when updating existing #{item}" do
if @item.respond_to?(:full_name)
previous_name_attributes = @item.attributes.slice('first_name', 'last_name')
@item.update(first_name: "Billy", last_name: "Bones")
else
previous_name_attributes = @item.attributes.slice('name')
@item.update(name: "Billy Bones")
end
@version = Version.where(@conditions.merge(event: 'update')).first

expect(@version.object).to be_present
expect(@version.reify.attributes).to include(previous_name_attributes)
end
end
end

Expand Down
Loading