Skip to content

Commit

Permalink
Ensure config#solr_response_model and config#solr_document_model are …
Browse files Browse the repository at this point in the history
…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
  • Loading branch information
cbeer committed Feb 16, 2015
1 parent 4707d4a commit a8d50fb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/blacklight/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -252,8 +252,13 @@ def deep_copy
end
alias_method :inheritable_copy, :deep_copy
else
alias_method :deep_copy, :deep_dup
alias_method :inheritable_copy, :deep_dup
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

##
Expand Down
10 changes: 10 additions & 0 deletions spec/lib/blacklight/configuration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit a8d50fb

Please sign in to comment.