From a04337f01e6dedbf83c493f790b77fab3e9265fc Mon Sep 17 00:00:00 2001 From: jrhoads Date: Mon, 23 Jan 2023 14:50:26 -0500 Subject: [PATCH 1/2] Rework subject serialization in for repositoris --- app/serializers/repository_serializer.rb | 4 +--- spec/requests/repositories_spec.rb | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/app/serializers/repository_serializer.rb b/app/serializers/repository_serializer.rb index 6765db9b8..34b3653be 100644 --- a/app/serializers/repository_serializer.rb +++ b/app/serializers/repository_serializer.rb @@ -97,9 +97,7 @@ class RepositorySerializer end end - attribute :subjects, - - Proc.new { |object, params| } do |object| + attribute :subjects do |object| if object.subjects? Array.wrap(object.subjects).map { |subject| subject.transform_keys! do |key| diff --git a/spec/requests/repositories_spec.rb b/spec/requests/repositories_spec.rb index 1d3b53cb1..955fc7121 100644 --- a/spec/requests/repositories_spec.rb +++ b/spec/requests/repositories_spec.rb @@ -387,6 +387,17 @@ } end + let(:empty_subject_attributes) do + { + "data" => { + "type" => "repositories", + "attributes" => { + "subjects" => nil, + }, + }, + } + end + it "updates the repository" do put "/repositories/#{client.symbol}", update_attributes, headers expect(json.dig("data", "attributes", "subjects")).to eq([ @@ -398,6 +409,11 @@ } ]) end + + it "accepts an empty array" do + put "/repositories/#{client.symbol}", empty_subject_attributes, headers + expect(json.dig("data", "attributes", "subjects")).to match_array([]) + end end From d7d9a4395d640e1cc4f70215610935242bdf0186 Mon Sep 17 00:00:00 2001 From: Mike Bennett Date: Wed, 25 Jan 2023 18:10:58 +0000 Subject: [PATCH 2/2] Explicitly set the is_write_index key on every switch_index option --- app/models/concerns/indexable.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/models/concerns/indexable.rb b/app/models/concerns/indexable.rb index 6c73a4297..27a66da69 100644 --- a/app/models/concerns/indexable.rb +++ b/app/models/concerns/indexable.rb @@ -1099,6 +1099,7 @@ def switch_index(options = {}) add: { index: index_name, alias: alias_name, + is_write_index: is_write_index, }, }, ],