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, }, }, ], 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 f901a4317..819459f15 100644 --- a/spec/requests/repositories_spec.rb +++ b/spec/requests/repositories_spec.rb @@ -389,6 +389,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([ @@ -400,6 +411,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