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

Drop Rails < 7.0, Ruby < 3.1, test against 7.1, 7.2, test against Ruby 3.3, fix ruby-head #152

Merged
merged 5 commits into from
Oct 2, 2024
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
36 changes: 4 additions & 32 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,47 +10,19 @@ jobs:
strategy:
fail-fast: false
matrix:
ruby: [3.2, 3.1, '3.0', 2.7, 2.6, ruby-head]
rails: ['7.0.0', '6.1.0', '6.0.0', '5.2.0', main]
ruby: [3.3, 3.2, 3.1, ruby-head]
rails: ['7.2.0', '7.1.0', '7.0.0', main]
exclude:
- ruby: ruby-head
rails: '6.1.0'
- ruby: ruby-head
rails: '6.0.0'
- ruby: ruby-head
rails: '5.2.0'
- ruby: 3.2
rails: '6.0.0'
- ruby: 3.2
rails: '5.2.0'
- ruby: 3.1
rails: '6.0.0'
rails: '7.0.0'
- ruby: 3.1
rails: '5.2.0'
- ruby: 3.0
rails: main
- ruby: 3.0
rails: '6.0.0'
- ruby: 3.0
rails: '5.2.0'
- ruby: 2.7
rails: main
- ruby: 2.7
rails: '5.2.0'
- ruby: 2.6
rails: main
- ruby: 2.6
rails: '7.0.0'
- ruby: 2.6
rails: '6.1.0'
- ruby: 2.6
rails: '6.0.0'

env:
RAILS_VERSION: ${{ matrix.rails }}

steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4
- name: Set up Ruby ${{ matrix.ruby }}
uses: ruby/setup-ruby@v1
with:
Expand Down
5 changes: 4 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
source 'https://rubygems.org'

rails_version = ENV['RAILS_VERSION'] || "default"
require_sqlite3_1x = %w[7.0.0].include?(rails_version)

rails =
case rails_version
when 'main'
{ github: 'rails/rails' }
when 'default'
'>= 5.0'
'>= 7.0'
else
"~> #{ENV['RAILS_VERSION']}"
end

gem 'rails', rails
gem 'sqlite3', '~> 1.3' if require_sqlite3_1x

gemspec
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Rails integration for [jsonapi-rb](http://jsonapi-rb.org).
## Status

[![Gem Version](https://badge.fury.io/rb/jsonapi-rails.svg)](https://badge.fury.io/rb/jsonapi-rails)
[![Build Status](https://github.com/jsonapi-rb/jsonapi-rails/actions/workflows/ci.yml/badge.svg)](https://github.com/jsonapi-rb/jsonapi-rails/actions/workflows/ci.yml/badge.svg)
[![Build Status](https://github.com/jsonapi-rb/jsonapi-rails/actions/workflows/ci.yml/badge.svg)](https://github.com/jsonapi-rb/jsonapi-rails/actions/workflows/ci.yml)
[![Gitter chat](https://badges.gitter.im/gitterHQ/gitter.svg)](https://gitter.im/jsonapi-rb/Lobby)

## Resources
Expand Down
4 changes: 3 additions & 1 deletion jsonapi-rails.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,12 @@ Gem::Specification.new do |spec|
spec.files = Dir['README.md', 'lib/**/*']
spec.require_path = 'lib'

spec.required_ruby_version = '>= 3.1.0'

spec.add_dependency 'jsonapi-rb', '~> 0.5.0'
spec.add_dependency 'jsonapi-parser', '~> 0.1.0'

spec.add_development_dependency 'rails', '>= 5.0'
spec.add_development_dependency 'rails', '>= 7.0'
spec.add_development_dependency 'sqlite3', '>= 1.3'
spec.add_development_dependency 'rake', '>= 11.3'
spec.add_development_dependency 'rspec-rails', '>= 4.0'
Expand Down
5 changes: 0 additions & 5 deletions spec/dummy/config/initializers/new_framework_defaults.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,5 @@
# Require `belongs_to` associations by default. Previous versions had false.
Rails.application.config.active_record.belongs_to_required_by_default = true

# Do not halt callback chains when a callback returns false. Previous versions had true.
if Rails.version < '5.2'
ActiveSupport.halt_callback_chains_on_return_false = false
end

# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
2 changes: 1 addition & 1 deletion spec/dummy/config/initializers/sqlite3_fix.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
if Rails.version >= '5.1.0' && Rails.application.config.active_record.sqlite3.present?
if Rails.application.config.active_record.sqlite3.present?
Rails.application.config.active_record.sqlite3.represent_boolean_as_integer = true
end
2 changes: 1 addition & 1 deletion spec/parsed_body_spec.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
require 'rails_helper'

describe ActionController::Base, type: :controller, if: Rails.version >= '6.0' do
describe ActionController::Base, type: :controller do
controller do
def index
render jsonapi: nil
Expand Down
8 changes: 5 additions & 3 deletions spec/render_jsonapi_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ def index

context 'when using a cache' do
controller do
User = Struct.new(:id, :name, :dob)

def serializer
Class.new(JSONAPI::Serializable::Resource) do
type 'users'
Expand All @@ -32,17 +34,17 @@ def jsonapi_cache_key(*)
end

def user
OpenStruct.new(id: 1, name: 'Johnny Cache', dob: Time.utc(2021,1,1))
User.new(1, 'Johnny Cache', Time.utc(2021,1,1))
end

def index
render jsonapi: [user],
class: { OpenStruct: serializer }
class: { User: serializer }
end

def index_with_caching
render jsonapi: [user],
class: { OpenStruct: serializer },
class: { User: serializer },
cache: Rails.cache
end
end
Expand Down