diff --git a/lib/blacklight/configuration.rb b/lib/blacklight/configuration.rb index 88ebe99fc2..8df92da75e 100644 --- a/lib/blacklight/configuration.rb +++ b/lib/blacklight/configuration.rb @@ -252,8 +252,16 @@ def deep_copy end alias_method :inheritable_copy, :deep_copy else - alias_method :deep_copy, :deep_dup - alias_method :inheritable_copy, :deep_dup + ## + # Rails 4.x provides `#deep_dup`, but it aggressively `#dup`'s class names + # too. These model names should not be `#dup`'ed or we might break ActiveModel::Naming. + def deep_copy + deep_dup.tap do |copy| + copy.solr_response_model = self.solr_response_model + copy.solr_document_model = self.solr_document_model + end + end + alias_method :inheritable_copy, :deep_copy end ## diff --git a/lib/blacklight/routes.rb b/lib/blacklight/routes.rb index 01eceea08c..e3b88fd5de 100644 --- a/lib/blacklight/routes.rb +++ b/lib/blacklight/routes.rb @@ -66,7 +66,10 @@ def bookmarks(_) get "bookmarks/sms", :as => "sms_bookmarks" post "bookmarks/sms" get "bookmarks/citation", :as => "citation_bookmarks" - resources :bookmarks + + args = {} + args[:constraints] = options[:constraints] if options[:constraints] + resources :bookmarks, args end end diff --git a/spec/lib/blacklight/configuration_spec.rb b/spec/lib/blacklight/configuration_spec.rb index 71970aacf2..1eb4d21572 100644 --- a/spec/lib/blacklight/configuration_spec.rb +++ b/spec/lib/blacklight/configuration_spec.rb @@ -84,6 +84,16 @@ expect(@config.facet_fields).to_not include(@mock_facet) end + it "should not dup solr_response_model or solr_document_model" do + @config.solr_response_model = Blacklight::SolrResponse + @config.solr_document_model = SolrDocument + + config_copy = @config.inheritable_copy + + expect(config_copy.solr_response_model).to eq Blacklight::SolrResponse + expect(config_copy.solr_document_model).to eq SolrDocument + end + it "should provide cloned copies of mutable data structures" do @config.a = { value: 1 } @config.b = [1,2,3]