From ee76e0c69b31528a223c57830ed178969b29b80b Mon Sep 17 00:00:00 2001 From: Shishir Kakaraddi Date: Sat, 3 Nov 2018 12:11:56 -0700 Subject: [PATCH 1/2] bump up version to 1.5 --- lib/fast_jsonapi/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/fast_jsonapi/version.rb b/lib/fast_jsonapi/version.rb index c9c4c7ab..12442c14 100644 --- a/lib/fast_jsonapi/version.rb +++ b/lib/fast_jsonapi/version.rb @@ -1,3 +1,3 @@ module FastJsonapi - VERSION = "1.4" + VERSION = "1.5" end From 22796a6a811750c3847d809b73bdaed6ca7b393a Mon Sep 17 00:00:00 2001 From: Daniel Illi Date: Thu, 22 Nov 2018 10:58:42 +0100 Subject: [PATCH 2/2] Fix error on defining anonymous serializer class, fixes #353 --- lib/fast_jsonapi/object_serializer.rb | 2 +- spec/lib/object_serializer_spec.rb | 19 +++++++++++++------ 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/lib/fast_jsonapi/object_serializer.rb b/lib/fast_jsonapi/object_serializer.rb index b8a24183..bc88ee7e 100644 --- a/lib/fast_jsonapi/object_serializer.rb +++ b/lib/fast_jsonapi/object_serializer.rb @@ -130,7 +130,7 @@ def reflected_record_type return @reflected_record_type if defined?(@reflected_record_type) @reflected_record_type ||= begin - if self.name.end_with?('Serializer') + if self.name && self.name.end_with?('Serializer') self.name.split('::').last.chomp('Serializer').underscore.to_sym end end diff --git a/spec/lib/object_serializer_spec.rb b/spec/lib/object_serializer_spec.rb index ef755ccc..7e46d907 100644 --- a/spec/lib/object_serializer_spec.rb +++ b/spec/lib/object_serializer_spec.rb @@ -314,6 +314,15 @@ class BlahBlahSerializer expect(BlahBlahSerializer.record_type).to be :blah_blah end + it 'should set default_type for a namespaced serializer' do + module V1 + class BlahSerializer + include FastJsonapi::ObjectSerializer + end + end + expect(V1::BlahSerializer.record_type).to be :blah + end + it 'shouldnt set default_type for a serializer that doesnt follow convention' do class BlahBlahSerializerBuilder include FastJsonapi::ObjectSerializer @@ -321,13 +330,11 @@ class BlahBlahSerializerBuilder expect(BlahBlahSerializerBuilder.record_type).to be_nil end - it 'should set default_type for a namespaced serializer' do - module V1 - class BlahSerializer - include FastJsonapi::ObjectSerializer - end + it 'shouldnt set default_type for an anonymous serializer' do + serializer_class = Class.new do + include FastJsonapi::ObjectSerializer end - expect(V1::BlahSerializer.record_type).to be :blah + expect(serializer_class.record_type).to be_nil end end