mirror of
https://github.com/samsonjs/grape-active_model_serializers.git
synced 2026-03-25 08:45:55 +00:00
Compare commits
9 commits
| Author | SHA1 | Date | |
|---|---|---|---|
| c985c86410 | |||
| 55f3861ae3 | |||
| af29f9c76e | |||
| 7ca250a305 | |||
| 61673fe322 | |||
| 26767f5fac | |||
| 6f1e4037bc | |||
|
|
cce31fe187 | ||
| 7f759b6560 |
8 changed files with 41 additions and 16 deletions
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
|
|
@ -8,7 +8,7 @@ jobs:
|
|||
- uses: actions/checkout@v4
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 3.4.4
|
||||
ruby-version: 4.0.0
|
||||
- name: Install dependencies
|
||||
run: bundle install --jobs 4 --retry 3
|
||||
- name: Run Danger
|
||||
|
|
@ -21,13 +21,18 @@ jobs:
|
|||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
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:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v6
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: ${{ matrix.ruby-version }}
|
||||
- name: Install dependencies
|
||||
run: bundle install --jobs 4 --retry 3
|
||||
env:
|
||||
GRAPE_VERSION: ${{ matrix.grape-version }}
|
||||
- name: Run tests
|
||||
run: bundle exec rake
|
||||
env:
|
||||
GRAPE_VERSION: ${{ matrix.grape-version }}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,14 @@
|
|||
## 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)
|
||||
|
||||
* [#96](https://github.com/ruby-grape/grape-active_model_serializers/pull/96): Add compatibility for Grape 2.3 - [@samsonjs](https://github.com/samsonjs).
|
||||
|
|
|
|||
2
Gemfile
2
Gemfile
|
|
@ -2,7 +2,7 @@ source 'https://rubygems.org'
|
|||
|
||||
gemspec
|
||||
|
||||
case version = ENV['GRAPE_VERSION'] || '~> 2.3.0'
|
||||
case version = ENV['GRAPE_VERSION'] || '~> 3.0.0'
|
||||
when 'HEAD'
|
||||
gem 'grape', github: 'intridea/grape'
|
||||
else
|
||||
|
|
|
|||
|
|
@ -49,11 +49,7 @@ module Grape
|
|||
end
|
||||
|
||||
def innermost_scope
|
||||
if endpoint.respond_to?(:namespace_stackable)
|
||||
endpoint.namespace_stackable(:namespace).last
|
||||
else
|
||||
endpoint.settings.peek[:namespace]
|
||||
end
|
||||
endpoint.inheritable_setting.namespace_stackable[:namespace]&.last
|
||||
end
|
||||
|
||||
def meta_options
|
||||
|
|
|
|||
|
|
@ -17,12 +17,14 @@ module Grape
|
|||
def serializer_class
|
||||
return @serializer_class if defined?(@serializer_class)
|
||||
|
||||
@serializer_class = resource_defined_class
|
||||
@serializer_class ||= collection_class
|
||||
@serializer_class ||= options[:serializer]
|
||||
@serializer_class ||= namespace_inferred_class
|
||||
@serializer_class ||= version_inferred_class
|
||||
@serializer_class ||= resource_serializer_class
|
||||
return nil if options.key?(:serializer) && options[:serializer].nil?
|
||||
|
||||
@serializer_class = resource_defined_class ||
|
||||
collection_class ||
|
||||
options[:serializer] ||
|
||||
namespace_inferred_class ||
|
||||
version_inferred_class ||
|
||||
resource_serializer_class
|
||||
end
|
||||
|
||||
def serializer_options
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
module Grape
|
||||
module ActiveModelSerializers
|
||||
VERSION = '2.0.0'.freeze
|
||||
VERSION = '2.0.2'.freeze
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -52,6 +52,18 @@ describe Grape::ActiveModelSerializers::SerializerResolver do
|
|||
expect(serializer).to be_kind_of(serializer_class)
|
||||
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
|
||||
let(:options) {
|
||||
super().except(:serializer).merge(
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ describe 'Sequel Integration' do
|
|||
let!(:model) {
|
||||
SequelUser = Class.new(Sequel::Model(:users)) do
|
||||
include ActiveModel::Serialization
|
||||
|
||||
def self.model_name
|
||||
'User'
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue