Skip to content

Commit

Permalink
WIP Add support for Ruby 3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
gbp committed Jan 12, 2023
1 parent 5a320d6 commit b5c3884
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 4 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ jobs:
include:
- { ruby: '3.0', postgres: 13.5 }
- { ruby: '3.0', postgres: 13.5, gemfile: 'Gemfile.rails_next' }
- { ruby: '3.1', postgres: 13.5 }
- { ruby: '3.1', postgres: 13.5, gemfile: 'Gemfile.rails_next' }

services:
postgres:
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 b5c3884

Please sign in to comment.