Compare commits

..

9 commits

Author SHA1 Message Date
c985c86410
Merge pull request #103 from samsonjs/ruby-4
Add Ruby 4.0.0 to test matrix
2026-01-02 11:52:32 -08:00
55f3861ae3
Set default Grape version to ~> 3.0.0 in Gemfile 2026-01-02 11:50:51 -08:00
af29f9c76e
Add Ruby 4.0.0 to test matrix 2026-01-02 11:50:39 -08:00
7ca250a305
Preparing for next development iteration, 2.0.2. 2025-12-08 13:42:40 -08:00
61673fe322
Preparing for release, 2.0.1. 2025-12-08 13:40:57 -08:00
26767f5fac
Merge pull request #100 from samsonjs/fix/99-grape-3-support
Add support for Grape 3.0 and test in CI
2025-12-08 13:36:32 -08:00
6f1e4037bc
Add support for Grape 3.0 and test in CI 2025-12-08 13:31:38 -08:00
Mateus Nava
cce31fe187
fix: Accept nil serializer (#92)
* fix: Accept nil serializer

* Obey the law

---------

Co-authored-by: Mateus Nava <mateus.nava@corp.globo.com>
Co-authored-by: Sami Samhuri <sami@samhuri.net>
2025-06-08 09:21:41 -04:00
7f759b6560
Preparing for next development iteration, 2.0.1. 2025-06-02 19:09:00 -07:00
8 changed files with 41 additions and 16 deletions

View file

@ -8,7 +8,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
with: with:
ruby-version: 3.4.4 ruby-version: 4.0.0
- name: Install dependencies - name: Install dependencies
run: bundle install --jobs 4 --retry 3 run: bundle install --jobs 4 --retry 3
- name: Run Danger - name: Run Danger
@ -21,13 +21,18 @@ jobs:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
matrix: matrix:
ruby-version: [3.4.4, 3.3.8, 3.2.8, 3.1.7] ruby-version: [4.0.0, 3.4.8, 3.3.10, 3.2.9]
grape-version: ['~> 3.0.0', '~> 2.3.0']
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v6
- uses: ruby/setup-ruby@v1 - uses: ruby/setup-ruby@v1
with: with:
ruby-version: ${{ matrix.ruby-version }} ruby-version: ${{ matrix.ruby-version }}
- name: Install dependencies - name: Install dependencies
run: bundle install --jobs 4 --retry 3 run: bundle install --jobs 4 --retry 3
env:
GRAPE_VERSION: ${{ matrix.grape-version }}
- name: Run tests - name: Run tests
run: bundle exec rake run: bundle exec rake
env:
GRAPE_VERSION: ${{ matrix.grape-version }}

View file

@ -1,5 +1,14 @@
## Changelog ## Changelog
### 2.0.2 (Next)
* Your contribution here.
### 2.0.1 (2025/12/08)
* [#92](https://github.com/ruby-grape/grape-active_model_serializers/pull/92): Fix: accept nil serializer - [@mateusnava](https://github.com/mateusnava).
* [#100](https://github.com/ruby-grape/grape-active_model_serializers/pull/100): Fix compatibility with Grape 3.0 and test in CI - [@samsonjs](https://github.com/samsonjs).
### 2.0.0 (2025/06/02) ### 2.0.0 (2025/06/02)
* [#96](https://github.com/ruby-grape/grape-active_model_serializers/pull/96): Add compatibility for Grape 2.3 - [@samsonjs](https://github.com/samsonjs). * [#96](https://github.com/ruby-grape/grape-active_model_serializers/pull/96): Add compatibility for Grape 2.3 - [@samsonjs](https://github.com/samsonjs).

View file

@ -2,7 +2,7 @@ source 'https://rubygems.org'
gemspec gemspec
case version = ENV['GRAPE_VERSION'] || '~> 2.3.0' case version = ENV['GRAPE_VERSION'] || '~> 3.0.0'
when 'HEAD' when 'HEAD'
gem 'grape', github: 'intridea/grape' gem 'grape', github: 'intridea/grape'
else else

View file

@ -49,11 +49,7 @@ module Grape
end end
def innermost_scope def innermost_scope
if endpoint.respond_to?(:namespace_stackable) endpoint.inheritable_setting.namespace_stackable[:namespace]&.last
endpoint.namespace_stackable(:namespace).last
else
endpoint.settings.peek[:namespace]
end
end end
def meta_options def meta_options

View file

@ -17,12 +17,14 @@ module Grape
def serializer_class def serializer_class
return @serializer_class if defined?(@serializer_class) return @serializer_class if defined?(@serializer_class)
@serializer_class = resource_defined_class return nil if options.key?(:serializer) && options[:serializer].nil?
@serializer_class ||= collection_class
@serializer_class ||= options[:serializer] @serializer_class = resource_defined_class ||
@serializer_class ||= namespace_inferred_class collection_class ||
@serializer_class ||= version_inferred_class options[:serializer] ||
@serializer_class ||= resource_serializer_class namespace_inferred_class ||
version_inferred_class ||
resource_serializer_class
end end
def serializer_options def serializer_options

View file

@ -1,5 +1,5 @@
module Grape module Grape
module ActiveModelSerializers module ActiveModelSerializers
VERSION = '2.0.0'.freeze VERSION = '2.0.2'.freeze
end end
end end

View file

@ -52,6 +52,18 @@ describe Grape::ActiveModelSerializers::SerializerResolver do
expect(serializer).to be_kind_of(serializer_class) expect(serializer).to be_kind_of(serializer_class)
end end
context 'specified nil by options' do
let(:options) {
super().merge(
serializer: nil
)
}
it 'returns nil' do
expect(serializer).to be_nil
end
end
context 'each serializer' do context 'each serializer' do
let(:options) { let(:options) {
super().except(:serializer).merge( super().except(:serializer).merge(

View file

@ -22,6 +22,7 @@ describe 'Sequel Integration' do
let!(:model) { let!(:model) {
SequelUser = Class.new(Sequel::Model(:users)) do SequelUser = Class.new(Sequel::Model(:users)) do
include ActiveModel::Serialization include ActiveModel::Serialization
def self.model_name def self.model_name
'User' 'User'
end end