Skip to content

Commit

Permalink
fix #358 by pointing the index.atom.builder spec to the live solr index
Browse files Browse the repository at this point in the history
  • Loading branch information
cbeer committed Apr 23, 2012
1 parent 25849b3 commit ad2c783
Showing 1 changed file with 13 additions and 39 deletions.
52 changes: 13 additions & 39 deletions test_support/spec/views/catalog/index.atom.builder_spec.rb
Expand Up @@ -4,57 +4,32 @@
describe "catalog/index" do

before(:all) do
@config ||= Blacklight::Configuration.from_legacy_configuration({
:show => {
:display_type => 'asdf'
},
:index_fields => {
:field_names => [],
:labels => {}
@config = Blacklight::Configuration.new.configure do |config|
config.default_solr_params = {
:fl => '*',
:rows => 10
}
})

@mock_configuration_module = Module.new do
# Just test against our default config for now.
def blacklight_config
@config ||= Blacklight::Config.new
end
end

class AtomMockDocument
include Blacklight::Solr::Document
end
@params = { 'content_format' => 'marc', :f => { :format => ['Book'] }, :page => 2 }

AtomMockDocument.field_semantics.merge!(
:title => "title_display",
:author => "author_display"
)
AtomMockDocument.extension_parameters[:marc_format_type] = :marc21
AtomMockDocument.extension_parameters[:marc_source_field] = :marc_display
AtomMockDocument.use_extension( Blacklight::Solr::Document::Marc) do |document|
document.key?( :marc_display )
end

# Load sample responses from Solr to a sample request, to test against
@data = YAML.load(File.open(File.dirname(__FILE__) +
"/../../data/sample_docs.yml", "r:UTF-8"))
@rsolr_response = RSolr::Ext::Response::Base.new(@data["solr_response"], nil, @data["params"])
@params = @data["params"]
@document_list = @data["document_list_mash"].collect do |d|
AtomMockDocument.new(d)
end
# run a solr query to get our data
c = CatalogController.new
c.blacklight_config = @config
@response, @document_list = c.get_search_results(@params)

# munge the solr response to match test expectations
@document_list[1] = SolrDocument.new(@document_list[1].to_mash.reject! { |k,v| k == "author_display" })
@document_list[5] = SolrDocument.new(@document_list[1].to_mash.reject! { |k,v| k == "marc_display" })
end
before(:each) do

# Not sure what Assigns was doing here ... dhf
# assigns[:response] = @rsolr_response
# assigns[:document_list] = @document_list
# not sure why we can't use assigns for 'params', instead this weird way,
# but okay.

params.merge!( @params )
@response = @rsolr_response

view.stub!(:blacklight_config).and_return(@config)
view.stub!(:search_field_options_for_select).and_return([])

Expand All @@ -64,7 +39,6 @@ class AtomMockDocument
render :template => 'catalog/index.atom'
end


# We need to use rexml to test certain things that have_tag wont' test
# note that response is depricated rails 3, use "redered" instead.
@response_xml = REXML::Document.new(rendered)
Expand Down

0 comments on commit ad2c783

Please sign in to comment.