Skip to content

Commit b799e21

Browse files
committed
Fix potential issue with default serializer inheritance/overriding
1 parent d9ba173 commit b799e21

File tree

5 files changed

+33
-10
lines changed

5 files changed

+33
-10
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## [0.0.12] - 2025-01-28
2+
3+
- Fix potential issue with default serializer inheritance/overriding
4+
15
## [0.0.11] - 2025-01-25
26

37
- Allow default_serializers to be changed

Gemfile.lock

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
foobara-http-command-connector (0.0.11)
4+
foobara-http-command-connector (0.0.12)
55
foobara
66

77
GEM
@@ -54,7 +54,7 @@ GEM
5454
foobara-type-generator
5555
foobara-typescript-react-command-form-generator
5656
foobara-typescript-remote-command-generator
57-
foobara (0.0.50)
57+
foobara (0.0.51)
5858
bigdecimal
5959
foobara-util
6060
foobara-autocrud-generator (0.0.1)
@@ -80,7 +80,7 @@ GEM
8080
foobara-files-generator
8181
foobara-files-generator (0.0.5)
8282
foobara
83-
foobara-local-files-crud-driver-generator (0.0.2)
83+
foobara-local-files-crud-driver-generator (0.0.3)
8484
foobara
8585
foobara-files-generator
8686
foobara-organization-generator (0.0.2)
@@ -141,7 +141,7 @@ GEM
141141
rspec (>= 2.99.0, < 4.0)
142142
hashdiff (1.1.2)
143143
json (2.9.1)
144-
language_server-protocol (3.17.0.3)
144+
language_server-protocol (3.17.0.4)
145145
listen (3.9.0)
146146
rb-fsevent (~> 0.10, >= 0.10.3)
147147
rb-inotify (~> 0.9, >= 0.9.10)
@@ -198,7 +198,7 @@ GEM
198198
rubocop-ast (>= 1.36.2, < 2.0)
199199
ruby-progressbar (~> 1.7)
200200
unicode-display_width (>= 2.4.0, < 4.0)
201-
rubocop-ast (1.37.0)
201+
rubocop-ast (1.38.0)
202202
parser (>= 3.3.1.0)
203203
rubocop-rake (0.6.0)
204204
rubocop (~> 1.0)

spec/foobara/command_connectors_http/http_spec.rb

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ def compute
5757

5858
let(:authenticator) { nil }
5959
let(:default_serializers) do
60-
[Foobara::CommandConnectors::Serializers::ErrorsSerializer, Foobara::CommandConnectors::Serializers::JsonSerializer]
60+
[Foobara::CommandConnectors::Serializers::ErrorsSerializer,
61+
Foobara::CommandConnectors::Serializers::JsonSerializer]
6162
end
6263
let(:default_pre_commit_transformer) { nil }
6364

@@ -650,7 +651,9 @@ def execute
650651

651652
context "with AggregateSerializer" do
652653
let(:serializers) { Foobara::CommandConnectors::Serializers::AggregateSerializer }
653-
let(:pre_commit_transformers) { Foobara::CommandConnectors::Transformers::LoadAggregatesPreCommitTransformer }
654+
let(:pre_commit_transformers) {
655+
Foobara::CommandConnectors::Transformers::LoadAggregatesPreCommitTransformer
656+
}
654657

655658
context "when user exists with a referral" do
656659
let(:command_class) do
@@ -1320,6 +1323,17 @@ def transform(result)
13201323
expect(subclass.default_serializers).to be_an(Array)
13211324
expect(subclass.default_serializers).to_not be_empty
13221325
end
1326+
1327+
context "when subclass of a subclass" do
1328+
let(:subsubclass) do
1329+
stub_class :SomeSubsubclass, subclass
1330+
end
1331+
1332+
it "returns some serializers" do
1333+
expect(subsubclass.default_serializers).to be_an(Array)
1334+
expect(subsubclass.default_serializers).to_not be_empty
1335+
end
1336+
end
13231337
end
13241338
end
13251339
end

src/http.rb

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,15 @@ class << self
99
def default_serializers
1010
return @default_serializers if @default_serializers
1111

12-
if superclass.respond_to?(:default_serializers)
13-
serializers = superclass.default_serializers
12+
superklass = superclass
13+
serializers = nil
14+
15+
while superklass.respond_to?(:default_serializers)
16+
serializers = superclass.instance_variable_get(:@default_serializers)
1417

1518
return serializers if serializers
19+
20+
superklass = superklass.superclass
1621
end
1722

1823
@default_serializers = [

version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module Foobara
22
module HttpCommandConnector
3-
VERSION = "0.0.11".freeze
3+
VERSION = "0.0.12".freeze
44

55
local_ruby_version = File.read("#{__dir__}/.ruby-version").chomp
66
local_ruby_version_minor = local_ruby_version[/\A(\d+\.\d+)\.\d+\z/, 1]

0 commit comments

Comments
 (0)