Skip to content

Relax gem requirement to allow Rails 7 #2428

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

Merged
merged 6 commits into from
Jan 3, 2022
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
6 changes: 6 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ jobs:
matrix:
include:
# Recent Rubies and Rails
- ruby-version: '3.1'
rails-version: '7.0'
- ruby-version: '3.0'
rails-version: '7.0'
- ruby-version: '2.7'
rails-version: '7.0'
- ruby-version: '2.6'
rails-version: '6.1'
- ruby-version: '2.6'
Expand Down
2 changes: 1 addition & 1 deletion active_model_serializers.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Gem::Specification.new do |spec|

spec.required_ruby_version = '>= 2.1'

rails_versions = ['>= 4.1', '< 7.0']
rails_versions = ['>= 4.1', '< 7.1']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

might as well remove the max version. only real benefit is it gets people to ask us to add a new version to CI

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@wasifhossain had a different idea but happy to go with the consensus.

spec.add_runtime_dependency 'activemodel', rails_versions
# 'activesupport', rails_versions
# 'builder'
Expand Down
7 changes: 6 additions & 1 deletion test/action_controller/serialization_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Serialization
class ImplicitSerializerTest < ActionController::TestCase
class ImplicitSerializationTestController < ActionController::Base
include SerializationTesting

def render_using_implicit_serializer
@profile = Profile.new(name: 'Name 1', description: 'Description 1', comments: 'Comments 1')
render json: @profile
Expand Down Expand Up @@ -75,8 +76,12 @@ def render_json_array_object_without_serializer
render json: [{ error: 'Result is Invalid' }]
end

# HACK: to prevent the resetting of instance variables after each request in Rails 7
# see https://github.com/rails/rails/pull/43735
def clear_instance_variables_between_requests; end

def update_and_render_object_with_cache_enabled
@post.updated_at = Time.zone.now
@post.updated_at = Time.zone.now # requires hack above to prevent `NoMethodError: undefined method `updated_at=' for nil:NilClass`

generate_cached_serializer(@post)
render json: @post
Expand Down