From 4ab2b197058e2153fd6d71448eb4c93cfb12a4e2 Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Mon, 16 Feb 2015 09:32:21 -0800 Subject: [PATCH 1/2] Bookmarks use the primary resource id in the URL, so they should use the same constraints --- lib/blacklight/routes.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 From 56c72cf754edbf68da5e4b79213eb51dc029f08f Mon Sep 17 00:00:00 2001 From: Chris Beer Date: Mon, 16 Feb 2015 09:22:42 -0800 Subject: [PATCH 2/2] Ensure config#solr_response_model and config#solr_document_model are not deep-dup'ed to preserve the original classes Fixes #1061 If those class names are dup'ed, methods that expect ActiveModel::Naming don't behave correctly --- lib/blacklight/configuration.rb | 12 ++++++++++-- spec/lib/blacklight/configuration_spec.rb | 10 ++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) 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/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]