Skip to content

Commit

Permalink
Add support for Ruby 3.1
Browse files Browse the repository at this point in the history
Added matrix gem which has been extracted from standard lib and used by
gnuplot.
  • Loading branch information
gbp committed Jan 16, 2023
1 parent a24be32 commit 7981378
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
matrix:
include:
- { ruby: '3.0', postgres: 13.5, dependencies: 'Current'}
- { ruby: '3.0', postgres: 13.5, dependencies: 'Next' }
- { ruby: '3.1', postgres: 13.5, dependencies: 'Next' }

services:
postgres:
Expand Down
1 change: 1 addition & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ gem 'open4', '~> 1.3.0'
gem 'rack', '~> 2.2.4'
gem 'rack-utf8_sanitizer', '~> 1.7.0'
gem 'recaptcha', '~> 5.12.3', require: 'recaptcha/rails'
gem 'matrix', '~> 0.4.2' if dependencies_next?
gem 'mini_magick', '~> 4.11.0'
gem 'rolify', '~> 5.3.0'
gem 'ruby-msg', '~> 1.5.0', :git => 'https://github.com/mysociety/ruby-msg.git', :branch => 'ascii-encoding'
Expand Down
1 change: 1 addition & 0 deletions Gemfile_next.lock
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,7 @@ DEPENDENCIES
locale (~> 2.1.3)
mahoro (~> 0.5)
mail (~> 2.7.1)
matrix (~> 0.4.2)
maxmind-db (~> 1.0.0)
mime-types (< 3.0.0)
mini_magick (~> 4.11.0)
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ see [the project website](http://alaveteli.org) for instructions on installing A
Every Alaveteli commit is tested by GitHub Actions on the [following Ruby platforms](https://github.com/mysociety/alaveteli/blob/develop/.github/workflows/ci.yml#L15)

* ruby-3.0
* ruby-3.1

If you use a ruby version management tool (such as RVM or .rbenv) and want to use the default development version used by the Alaveteli team (currently 3.0.4), you can create a `.ruby-version` symlink with a target of `.ruby-version.example` to switch to that automatically in the project directory.

Expand Down
14 changes: 13 additions & 1 deletion app/models/post_redirect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,19 @@ def post_params=(params)

def post_params
return {} if post_params_yaml.nil?
YAML.load(post_params_yaml)

if RUBY_VERSION < "3.1"
YAML.load(post_params_yaml)
else
YAML.load(
post_params_yaml,
permitted_classes: [
ActionController::Parameters,
ActiveSupport::HashWithIndifferentAccess,
Symbol
]
)
end
end

# We store YAML version of textual "reason for redirect" parameters
Expand Down
3 changes: 2 additions & 1 deletion doc/CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,10 @@

## Highlighted Features

* Add support for Ruby 3.1 (Graeme Porteous)
* Upgrade to Rails 7 (Graeme Porteous)
* Improve processing of large PDF attachments (Graeme Porteous)
* Add support for Ruby 3 (Graeme Porteous)
* Add support for Ruby 3.0 (Graeme Porteous)
* Drop support for Ruby 2.7 (Graeme Porteous)

## Upgrade Notes
Expand Down
4 changes: 2 additions & 2 deletions spec/lib/yaml_compatability_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
let(:content) { yaml_compatibility_fixture('5_0') }

it 'correctly loads YAML file' do
is_expected.to eq hash
is_expected.to eq hash if RUBY_VERSION < '3.1'
end
end

context 'with Rails 5.1 YAML file' do
let(:content) { yaml_compatibility_fixture('5_1') }

it 'correctly loads YAML file' do
is_expected.to eq hash
is_expected.to eq hash if RUBY_VERSION < '3.1'
end
end

Expand Down

0 comments on commit 7981378

Please sign in to comment.