blacklight 3.0pre1 → 3.0pre2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.gitmodules +0 -6
- data/README.rdoc +94 -87
- data/blacklight.gemspec +1 -1
- data/config/routes.rb +1 -1
- data/lib/blacklight.rb +2 -2
- data/lib/blacklight/catalog.rb +10 -12
- data/lib/blacklight/controller.rb +2 -2
- data/lib/blacklight/engine.rb +5 -2
- data/lib/blacklight/solr/document.rb +1 -1
- data/lib/blacklight/solr/document/marc.rb +1 -16
- data/lib/blacklight/solr_helper.rb +43 -14
- data/lib/blacklight/version.rb +1 -1
- data/lib/generators/blacklight/assets_generator.rb +25 -0
- data/lib/generators/blacklight/blacklight_generator.rb +16 -1
- data/lib/generators/blacklight/jetty_generator.rb +101 -0
- data/lib/generators/blacklight/solr_conf_generator.rb +25 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +0 -1
- data/lib/generators/blacklight/templates/config/solr.yml +14 -2
- data/lib/generators/blacklight/templates/public/images/{blacklight/bg.png → bg.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/border.png → border.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/bul_sq_gry.gif → bul_sq_gry.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/checkmark.gif → checkmark.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/logo.png → logo.png} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/magnifying_glass.gif → magnifying_glass.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/remove.gif → remove.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/separator.gif → separator.gif} +0 -0
- data/lib/generators/blacklight/templates/public/images/{blacklight/start_over.gif → start_over.gif} +0 -0
- data/lib/generators/blacklight/templates/public/javascripts/blacklight.js +5 -0
- data/lib/generators/blacklight/templates/public/stylesheets/blacklight.css +9 -3
- data/lib/generators/blacklight/templates/solr_conf/schema.xml +339 -0
- data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +578 -0
- data/lib/railties/all_tests.rake +11 -0
- data/lib/railties/blacklight.rake +0 -52
- data/lib/railties/blacklight_cucumber.rake +125 -0
- data/lib/railties/blacklight_rspec.rake +128 -0
- data/lib/railties/{test_solr_server.rb → jetty_solr_server.rb} +22 -45
- data/lib/railties/solr_marc.rake +24 -5
- data/test_support/.rspec +1 -0
- data/test_support/data/test_data.utf8.mrc +1 -0
- data/test_support/features/bookmarks.feature +88 -0
- data/test_support/features/did_you_mean.feature +129 -0
- data/test_support/features/folder.feature +67 -0
- data/test_support/features/librarian_view.feature +17 -0
- data/test_support/features/record_view.feature +34 -0
- data/test_support/features/saved_searches.feature +49 -0
- data/test_support/features/search.feature +86 -0
- data/test_support/features/search_filters.feature +121 -0
- data/test_support/features/search_history.feature +95 -0
- data/test_support/features/search_results.feature +61 -0
- data/test_support/features/search_sort.feature +29 -0
- data/test_support/features/step_definitions/bookmarks_steps.rb +5 -0
- data/test_support/features/step_definitions/error_steps.rb +4 -0
- data/test_support/features/step_definitions/folder_steps.rb +26 -0
- data/test_support/features/step_definitions/general_steps.rb +49 -0
- data/test_support/features/step_definitions/record_view_steps.rb +11 -0
- data/test_support/features/step_definitions/saved_searches_steps.rb +21 -0
- data/test_support/features/step_definitions/search_facets_steps.rb +28 -0
- data/test_support/features/step_definitions/search_history_steps.rb +8 -0
- data/test_support/features/step_definitions/search_result_steps.rb +113 -0
- data/test_support/features/step_definitions/search_steps.rb +102 -0
- data/test_support/features/step_definitions/user_steps.rb +4 -0
- data/test_support/features/step_definitions/web_steps.rb +211 -0
- data/test_support/features/support/env.rb +49 -0
- data/test_support/features/support/paths.rb +55 -0
- data/test_support/features/support/selectors.rb +39 -0
- data/test_support/features/unapi.feature +30 -0
- data/test_support/spec/controllers/application_controller_spec.rb +22 -0
- data/test_support/spec/controllers/catalog_controller_spec.rb +480 -0
- data/test_support/spec/controllers/folder_controller_spec.rb +40 -0
- data/test_support/spec/controllers/search_history_controller_spec.rb +45 -0
- data/test_support/spec/data/sample_docs.yml +655 -0
- data/test_support/spec/data/test_data.utf8.mrc +1 -0
- data/test_support/spec/helpers/blacklight_helper_spec.rb +482 -0
- data/test_support/spec/helpers/hash_as_hidden_fields_spec.rb +23 -0
- data/test_support/spec/helpers/render_constraints_helper_spec.rb +64 -0
- data/test_support/spec/helpers/search_history_helper_spec.rb +11 -0
- data/test_support/spec/helpers/solr_helper_spec.rb +873 -0
- data/test_support/spec/lib/blacklight_email_spec.rb +23 -0
- data/test_support/spec/lib/blacklight_sms_spec.rb +23 -0
- data/test_support/spec/lib/blacklight_solr_document_dublin_core_spec.rb +41 -0
- data/test_support/spec/lib/blacklight_solr_document_marc_spec.rb +88 -0
- data/test_support/spec/lib/blacklight_solr_document_spec.rb +173 -0
- data/test_support/spec/lib/blacklight_spec.rb +39 -0
- data/test_support/spec/lib/configurable_spec.rb +97 -0
- data/test_support/spec/lib/facet_paginator_spec.rb +93 -0
- data/test_support/spec/lib/marc_export_spec.rb +444 -0
- data/test_support/spec/lib/search_fields_spec.rb +105 -0
- data/test_support/spec/lib/tasks/blacklight_task_spec.rb +21 -0
- data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +59 -0
- data/test_support/spec/models/bookmark_spec.rb +37 -0
- data/test_support/spec/models/record_mailer_spec.rb +67 -0
- data/test_support/spec/models/search_spec.rb +55 -0
- data/test_support/spec/models/solr_docment_spec.rb +111 -0
- data/test_support/spec/rcov.opts +3 -0
- data/test_support/spec/spec.opts +4 -0
- data/test_support/spec/spec_helper.rb +38 -0
- data/test_support/spec/support/action_controller.rb +42 -0
- data/test_support/spec/support/assert_difference.rb +16 -0
- data/test_support/spec/support/include_text.rb +20 -0
- data/test_support/spec/views/catalog/_constraints_element.html.erb_spec.rb +59 -0
- data/test_support/spec/views/catalog/_document_list.html.erb_spec.rb +8 -0
- data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +182 -0
- data/test_support/spec/views/catalog/_index_partials/_default.erb_spec.rb +70 -0
- data/test_support/spec/views/catalog/_show_partials/_default.html.erb_spec.rb +70 -0
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +141 -0
- data/test_support/spec/views/catalog/show.html.erb_spec.rb +100 -0
- data/test_support/spec/views/catalog/unapi.xml.builder_spec.rb +45 -0
- metadata +95 -98
- data/lib/blacklight/marc.rb +0 -46
- data/lib/blacklight/marc/citation.rb +0 -251
- data/lib/railties/cucumber.rake +0 -53
- data/lib/railties/rspec.rake +0 -188
- data/spec/helpers/catalog_helper_spec.rb +0 -111
- data/spec/views/catalog/_sms_form.html.erb_spec.rb +0 -19
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
# This file is copied to spec/ when you run 'rails generate rspec:install'
|
|
2
|
+
# Has been customized by Blacklight to work when application is in one place,
|
|
3
|
+
# and actual spec/ stuff is in another (the blacklight gem checkout).
|
|
4
|
+
|
|
5
|
+
ENV["RAILS_ENV"] ||= 'test'
|
|
6
|
+
|
|
7
|
+
#require File.expand_path("../../config/environment", __FILE__)
|
|
8
|
+
# version that works with our blacklight:spec stuff that calls specs
|
|
9
|
+
# in a remote directory.
|
|
10
|
+
require File.expand_path("config/environment", ENV['RAILS_ROOT'] || File.expand_path("../..", __FILE__))
|
|
11
|
+
require 'rspec/rails'
|
|
12
|
+
|
|
13
|
+
# Requires supporting ruby files with custom matchers and macros, etc,
|
|
14
|
+
# in spec/support/ and its subdirectories.
|
|
15
|
+
# Blacklight, again, make sure we're looking in the right place for em.
|
|
16
|
+
# Relative to HERE, NOT to Rails.root, which is off somewhere else.
|
|
17
|
+
#Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
|
|
18
|
+
Dir[Pathname.new(File.expand_path("../support/**/*.rb", __FILE__))].each {|f| require f}
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
RSpec.configure do |config|
|
|
22
|
+
# == Mock Framework
|
|
23
|
+
#
|
|
24
|
+
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
|
|
25
|
+
#
|
|
26
|
+
# config.mock_with :mocha
|
|
27
|
+
# config.mock_with :flexmock
|
|
28
|
+
# config.mock_with :rr
|
|
29
|
+
config.mock_with :rspec
|
|
30
|
+
|
|
31
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
32
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
33
|
+
|
|
34
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
35
|
+
# examples within a transaction, remove the following line or assign false
|
|
36
|
+
# instead of true.
|
|
37
|
+
config.use_transactional_fixtures = true
|
|
38
|
+
end
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
# Added based on http://www.arctickiwi.com/blog/upgrading-to-rspec-2-with-ruby-on-rails-3
|
|
2
|
+
# God bless you Jonathon Horsman
|
|
3
|
+
module ActionController
|
|
4
|
+
class TestCase < ActiveSupport::TestCase
|
|
5
|
+
module Behavior
|
|
6
|
+
def process(action, parameters = nil, session = nil, flash = nil, http_method = 'GET')
|
|
7
|
+
# Sanity check for required instance variables so we can give an
|
|
8
|
+
# understandable error message.
|
|
9
|
+
%w(@routes @controller @request @response).each do |iv_name|
|
|
10
|
+
if !(instance_variable_names.include?(iv_name) || instance_variable_names.include?(iv_name.to_sym)) || instance_variable_get(iv_name).nil?
|
|
11
|
+
raise "#{iv_name} is nil: make sure you set it in your test's setup method."
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
@request.recycle!
|
|
16
|
+
@response.recycle!
|
|
17
|
+
@controller.response_body = nil
|
|
18
|
+
@controller.formats = nil
|
|
19
|
+
@controller.params = nil
|
|
20
|
+
|
|
21
|
+
@html_document = nil
|
|
22
|
+
@request.env['REQUEST_METHOD'] = http_method
|
|
23
|
+
|
|
24
|
+
parameters ||= {}
|
|
25
|
+
@request.assign_parameters(@routes, @controller.class.name.underscore.sub(/_controller$/, ''), action.to_s, parameters)
|
|
26
|
+
|
|
27
|
+
@request.session = ActionController::TestSession.new(session) unless session.nil?
|
|
28
|
+
@request.session["flash"] = @request.flash.update(flash || {})
|
|
29
|
+
@request.session["flash"].sweep
|
|
30
|
+
|
|
31
|
+
@controller.request = @request
|
|
32
|
+
#@controller.params.merge!(parameters) # this is the offending line, which I removed
|
|
33
|
+
build_request_uri(action, parameters)
|
|
34
|
+
Base.class_eval { include Testing }
|
|
35
|
+
@controller.process_with_new_base_test(@request, @response)
|
|
36
|
+
@request.session.delete('flash') if @request.session['flash'].blank?
|
|
37
|
+
@response
|
|
38
|
+
end
|
|
39
|
+
end
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Added based on http://www.arctickiwi.com/blog/upgrading-to-rspec-2-with-ruby-on-rails-3
|
|
2
|
+
# God bless you Jonathon Horsman
|
|
3
|
+
def assert_difference(executable, how_many = 1, &block)
|
|
4
|
+
before = eval(executable)
|
|
5
|
+
yield
|
|
6
|
+
after = eval(executable)
|
|
7
|
+
after.should == before + how_many
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
def assert_no_difference(executable, &block)
|
|
11
|
+
before = eval(executable)
|
|
12
|
+
yield
|
|
13
|
+
after = eval(executable)
|
|
14
|
+
after.should == before
|
|
15
|
+
end
|
|
16
|
+
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# Added from http://www.arctickiwi.com/blog/upgrading-to-rspec-2-with-ruby-on-rails-3
|
|
2
|
+
module RSpec::Rails
|
|
3
|
+
module Matchers
|
|
4
|
+
RSpec::Matchers.define :include_text do |text|
|
|
5
|
+
match do |response_or_text|
|
|
6
|
+
@content = response_or_text.respond_to?(:body) ? response_or_text.body : response_or_text
|
|
7
|
+
@content.include?(text)
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
failure_message_for_should do |text|
|
|
11
|
+
"expected '#{@content}' to contain '#{text}'"
|
|
12
|
+
end
|
|
13
|
+
|
|
14
|
+
failure_message_for_should_not do |text|
|
|
15
|
+
"expected #{@content} to not contain '#{text}'"
|
|
16
|
+
end
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "catalog/_constraints_element.html.erb" do
|
|
4
|
+
describe "for simple display" do
|
|
5
|
+
before do
|
|
6
|
+
render :partial => "catalog/constraints_element", :locals => {:label => "my label", :value => "my value"}
|
|
7
|
+
end
|
|
8
|
+
it "should render label and value" do
|
|
9
|
+
rendered.should have_selector("span.appliedFilter.constraint") do |s|
|
|
10
|
+
s.should have_selector "span.filterName", :content => "my label"
|
|
11
|
+
s.should have_selector "span.filterValue", :content => "my value"
|
|
12
|
+
end
|
|
13
|
+
end
|
|
14
|
+
end
|
|
15
|
+
|
|
16
|
+
describe "with remove link" do
|
|
17
|
+
before do
|
|
18
|
+
render :partial => "catalog/constraints_element", :locals => {:label => "my label", :value => "my value", :options => {:remove => "http://remove"}}
|
|
19
|
+
end
|
|
20
|
+
it "should include remove link" do
|
|
21
|
+
rendered.should have_selector("span.appliedFilter") do |s|
|
|
22
|
+
s.should have_selector("a.btnRemove.imgReplace[href='http://remove']")
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
describe "with checkmark suppressed" do
|
|
28
|
+
before do
|
|
29
|
+
render :partial => "catalog/constraints_element", :locals => {:label => "my label", :value => "my value", :options => {:check => false}}
|
|
30
|
+
end
|
|
31
|
+
it "should not include checkmark" do
|
|
32
|
+
rendered.should have_selector("span.appliedFilter") do |s|
|
|
33
|
+
s.should_not have_selector("img[src$='checkmark.gif']")
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
describe "with custom classes" do
|
|
39
|
+
before do
|
|
40
|
+
render :partial => "catalog/constraints_element", :locals => {:label => "my label", :value => "my value", :options => {:classes => ["class1", "class2"]}}
|
|
41
|
+
end
|
|
42
|
+
it "should include them" do
|
|
43
|
+
rendered.should have_selector("span.appliedFilter.constraint.class1.class2")
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
describe "with no escaping" do
|
|
48
|
+
before do
|
|
49
|
+
render( :partial => "catalog/constraints_element", :locals => {:label => "<span class='custom_label'>my label</span>", :value => "<span class='custom_value'>my value</span>", :options => {:escape_label => false, :escape_value => false}} )
|
|
50
|
+
end
|
|
51
|
+
it "should not escape key and value" do
|
|
52
|
+
rendered.should have_selector("span.appliedFilter.constraint span.filterName span.custom_label")
|
|
53
|
+
rendered.should have_selector("span.appliedFilter.constraint span.filterValue span.custom_value")
|
|
54
|
+
end
|
|
55
|
+
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
end
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
|
+
|
|
3
|
+
describe "/catalog/_facets.html.erb" do
|
|
4
|
+
|
|
5
|
+
before(:each) do
|
|
6
|
+
|
|
7
|
+
# create mock facets to be retrieved from the response
|
|
8
|
+
@solr_item00 = stub("solr_item00")
|
|
9
|
+
@solr_item00.stub!(:value).and_return("val_0_0")
|
|
10
|
+
@solr_item00.stub!(:hits).and_return("90")
|
|
11
|
+
@solr_item01 = stub("solr_item01")
|
|
12
|
+
@solr_item01.stub!(:value).and_return("val_0_1")
|
|
13
|
+
@solr_item01.stub!(:hits).and_return("91")
|
|
14
|
+
@facet0 = stub("facet0")
|
|
15
|
+
@solr_fname0 = Blacklight.config[:facet][:field_names].last
|
|
16
|
+
@facet0.stub!(:name).and_return(@solr_fname0);
|
|
17
|
+
@solr_items0 = [@solr_item00, @solr_item01]
|
|
18
|
+
@facet0.stub!(:items).and_return(@solr_items0);
|
|
19
|
+
|
|
20
|
+
@solr_item10 = stub("solr_item10")
|
|
21
|
+
@solr_item10.stub!(:value).and_return("val_1_0")
|
|
22
|
+
@solr_item10.stub!(:hits).and_return("10")
|
|
23
|
+
@solr_item11 = stub("solr_item11")
|
|
24
|
+
@solr_item11.stub!(:value).and_return("val_1_1")
|
|
25
|
+
@solr_item11.stub!(:hits).and_return("11")
|
|
26
|
+
@facet1 = stub("facet1")
|
|
27
|
+
@solr_fname1 = Blacklight.config[:facet][:field_names][1]
|
|
28
|
+
@facet1.stub!(:name).and_return(@solr_fname1);
|
|
29
|
+
@solr_items1 = [@solr_item10, @solr_item11]
|
|
30
|
+
@facet1.stub!(:items).and_return(@solr_items1);
|
|
31
|
+
|
|
32
|
+
@solr_item20 = stub("solr_item20")
|
|
33
|
+
@solr_item20.stub!(:value).and_return("val_2_0")
|
|
34
|
+
@solr_item20.stub!(:hits).and_return("20")
|
|
35
|
+
@solr_item21 = stub("solr_item21")
|
|
36
|
+
@solr_item21.stub!(:value).and_return("val_2_1")
|
|
37
|
+
@solr_item21.stub!(:hits).and_return("21")
|
|
38
|
+
@facet2 = stub("facet2")
|
|
39
|
+
@solr_fname2 = Blacklight.config[:facet][:field_names][0]
|
|
40
|
+
@facet2.stub!(:name).and_return(@solr_fname2);
|
|
41
|
+
@solr_items2 = [@solr_item20, @solr_item21]
|
|
42
|
+
@facet2.stub!(:items).and_return(@solr_items2);
|
|
43
|
+
|
|
44
|
+
@solr_item30 = stub("solr_item30")
|
|
45
|
+
@solr_item30.stub!(:value).and_return("val_3_0")
|
|
46
|
+
@solr_item30.stub!(:hits).and_return("30")
|
|
47
|
+
@solr_item31 = stub("solr_item31")
|
|
48
|
+
@solr_item31.stub!(:value).and_return("val_3_1")
|
|
49
|
+
@solr_item31.stub!(:hits).and_return("31")
|
|
50
|
+
@facet3 = stub("facet3")
|
|
51
|
+
@solr_fname3 = "solr_field_not_in_initializer_facet"
|
|
52
|
+
@facet3.stub!(:name).and_return(@solr_fname3);
|
|
53
|
+
@solr_items3 = [@solr_item30, @solr_item31]
|
|
54
|
+
@facet3.stub!(:items).and_return(@solr_items3);
|
|
55
|
+
|
|
56
|
+
@facets = [@facet0, @facet1, @facet2, @facet3]
|
|
57
|
+
@response.stub!(:facets).and_return(@facets)
|
|
58
|
+
|
|
59
|
+
# one facet is selected
|
|
60
|
+
selected_facet = {@solr_fname1 => [@solr_item10.value]}
|
|
61
|
+
params[:f] = selected_facet
|
|
62
|
+
|
|
63
|
+
assigns[:response] = @response
|
|
64
|
+
|
|
65
|
+
render :partial => 'catalog/facets'
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
# There is a problem with link_to and rspec-rails. See:
|
|
69
|
+
# http://www.nabble.com/Rails:-View-specs-and-implicit-parameters-in-link_to()-td20011051.html
|
|
70
|
+
# This spec will run cleanly if the implicit routes are added to the plugin
|
|
71
|
+
# level routes.rb file: (at the bottom of the file)
|
|
72
|
+
#
|
|
73
|
+
# map.connect ':controller/:action/:id'
|
|
74
|
+
# map.connect ':controller/:action/:id.:format'
|
|
75
|
+
|
|
76
|
+
# If someone can find a better workaround, that would be mega-spiffy.
|
|
77
|
+
#
|
|
78
|
+
# For now, I am commenting out this spec because I'm not sure if adding those
|
|
79
|
+
# routes will affect anything else. Similar comments are in routes.rb
|
|
80
|
+
# - Naomi 2009-04-19
|
|
81
|
+
|
|
82
|
+
=begin
|
|
83
|
+
|
|
84
|
+
it "should have div tag with id=facets" do
|
|
85
|
+
response.should have_selector('div[id=facets]')
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
it "should not have facets that aren't specified in initializer" do
|
|
89
|
+
response.should_not include_text(@solr_fname3)
|
|
90
|
+
end
|
|
91
|
+
|
|
92
|
+
it "should skip over facets specified in the initializer that aren't in the response" do
|
|
93
|
+
solr_field = Blacklight.config[:facet][:field_names][2]
|
|
94
|
+
label = Blacklight.config[:facet][:labels][solr_field]
|
|
95
|
+
response.should_not include_text(label)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
it "should have all facets specified in initializer that are included in solr response" do
|
|
99
|
+
solr_field1 = Blacklight.config[:facet][:field_names].last
|
|
100
|
+
response.should include_text(solr_field1)
|
|
101
|
+
|
|
102
|
+
solr_field2 = Blacklight.config[:facet][:field_names][1]
|
|
103
|
+
response.should include_text(solr_field2)
|
|
104
|
+
|
|
105
|
+
solr_field3 = Blacklight.config[:facet][:field_names][0]
|
|
106
|
+
response.should include_text(solr_field3)
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
it "should use the labels specified in initializer" do
|
|
110
|
+
label1 = Blacklight.config[:facet][:labels][@solr_fname0]
|
|
111
|
+
response.should include_text(label1)
|
|
112
|
+
|
|
113
|
+
label2 = Blacklight.config[:facet][:labels][@solr_fname1]
|
|
114
|
+
response.should include_text(label2)
|
|
115
|
+
|
|
116
|
+
label3 = Blacklight.config[:facet][:labels][@solr_fname2]
|
|
117
|
+
response.should include_text(label3)
|
|
118
|
+
end
|
|
119
|
+
|
|
120
|
+
# TODO: check the display order of the facets. Naomi can't figure this out
|
|
121
|
+
# it "should display the facets in the order specified in the initializer" do
|
|
122
|
+
# pending
|
|
123
|
+
# end
|
|
124
|
+
#
|
|
125
|
+
# output is:
|
|
126
|
+
# <div id="facets">
|
|
127
|
+
# <div>
|
|
128
|
+
# <h3>Format</h3>
|
|
129
|
+
# <ul>
|
|
130
|
+
# <li>Book</li>
|
|
131
|
+
# <li>Online</li>
|
|
132
|
+
# </ul>
|
|
133
|
+
# </div>
|
|
134
|
+
# <div>
|
|
135
|
+
# <h3>Language</h3>
|
|
136
|
+
# <ul>
|
|
137
|
+
# <li>English</li>
|
|
138
|
+
# <li>Urdu/li>
|
|
139
|
+
# </ul>
|
|
140
|
+
# </div>
|
|
141
|
+
# </div>
|
|
142
|
+
#
|
|
143
|
+
# can't test for ordering of h3 contents:
|
|
144
|
+
# they are not immediate children of <div id="facets">
|
|
145
|
+
#
|
|
146
|
+
# perhaps use Cucumber?
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
it "should have values for displayed facets" do
|
|
150
|
+
response.should have_selector("li") do
|
|
151
|
+
with_tag("a", @solr_item00.value)
|
|
152
|
+
with_tag("a", @solr_item01.value)
|
|
153
|
+
# with_tag("a", @solr_item10.value) # this facet is selected
|
|
154
|
+
with_tag("a", @solr_item11.value)
|
|
155
|
+
with_tag("a", @solr_item20.value)
|
|
156
|
+
with_tag("a", @solr_item21.value)
|
|
157
|
+
end
|
|
158
|
+
end
|
|
159
|
+
|
|
160
|
+
it "should have numbers of hits for displayed facets" do
|
|
161
|
+
response.should include_text(@solr_item00.hits)
|
|
162
|
+
response.should include_text(@solr_item01.hits)
|
|
163
|
+
response.should include_text(@solr_item10.hits)
|
|
164
|
+
response.should include_text(@solr_item11.hits)
|
|
165
|
+
response.should include_text(@solr_item20.hits)
|
|
166
|
+
response.should include_text(@solr_item21.hits)
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
it "should have links to include facet values in solr query" do
|
|
170
|
+
response.should have_selector("a", :text => @solr_item00.value)
|
|
171
|
+
response.should include_text("f%5B"+@solr_fname0 + "%5D%5B%5D=" + @solr_item00.value)
|
|
172
|
+
response.should have_selector("a", :text => @solr_item11.value)
|
|
173
|
+
response.should include_text("f%5B"+@solr_fname1 + "%5D%5B%5D=" + @solr_item11.value)
|
|
174
|
+
end
|
|
175
|
+
|
|
176
|
+
it "should display selected facets properly" do
|
|
177
|
+
response.should have_selector("span[class=selected]", :text => /#{@solr_item10.value}/)
|
|
178
|
+
end
|
|
179
|
+
|
|
180
|
+
=end
|
|
181
|
+
|
|
182
|
+
end
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../../../spec_helper')
|
|
2
|
+
|
|
3
|
+
# spec for default partial to display solr document fields
|
|
4
|
+
# in catalog INDEX view
|
|
5
|
+
|
|
6
|
+
describe "/catalog/_index_partials/_default.erb" do
|
|
7
|
+
|
|
8
|
+
include BlacklightHelper
|
|
9
|
+
include CatalogHelper
|
|
10
|
+
|
|
11
|
+
before(:each) do
|
|
12
|
+
@fname_1 = Blacklight.config[:index_fields][:field_names].last
|
|
13
|
+
@fname_2 = "solr_field_not_in_initializer"
|
|
14
|
+
@fname_3 = Blacklight.config[:index_fields][:field_names][1]
|
|
15
|
+
@fname_4 = Blacklight.config[:index_fields][:field_names][0]
|
|
16
|
+
|
|
17
|
+
@document = mock("solr_doc")
|
|
18
|
+
@document.should_receive(:get).with(@fname_1, hash_including(:sep => nil)).any_number_of_times.and_return("val_1")
|
|
19
|
+
@document.should_receive(:get).with(@fname_2, hash_including(:sep => nil)).any_number_of_times.and_return("val_2")
|
|
20
|
+
@document.should_receive(:get).with(@fname_3, hash_including(:sep => nil)).any_number_of_times.and_return(nil)
|
|
21
|
+
@document.should_receive(:get).with(@fname_4, hash_including(:sep => nil)).any_number_of_times.and_return("val_4")
|
|
22
|
+
|
|
23
|
+
@document.should_receive(:'has?').with(@fname_1).any_number_of_times.and_return(true)
|
|
24
|
+
@document.should_receive(:'has?').with(@fname_2).any_number_of_times.and_return(true)
|
|
25
|
+
@document.should_receive(:'has?').with(@fname_3).any_number_of_times.and_return(false)
|
|
26
|
+
@document.should_receive(:'has?').with(@fname_4).any_number_of_times.and_return(true)
|
|
27
|
+
@document.should_receive(:'has?').with(anything()).any_number_of_times.and_return(true)
|
|
28
|
+
|
|
29
|
+
# cover any remaining fields in initalizer
|
|
30
|
+
@document.should_receive(:get).with(anything(), hash_including(:sep => nil)).any_number_of_times.and_return("bleah")
|
|
31
|
+
@document.should_receive(:[]).any_number_of_times
|
|
32
|
+
|
|
33
|
+
@flabel_1 = Blacklight.config[:index_fields][:labels][@fname_1]
|
|
34
|
+
@flabel_3 = Blacklight.config[:index_fields][:labels][@fname_3]
|
|
35
|
+
@flabel_4 = Blacklight.config[:index_fields][:labels][@fname_4]
|
|
36
|
+
|
|
37
|
+
assigns[:document] = @document
|
|
38
|
+
render_document_partial @document, :index
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
it "should only display fields listed in the initializer" do
|
|
42
|
+
rendered.should_not include_text("val_2")
|
|
43
|
+
rendered.should_not include_text(@fname_2)
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
it "should skip over fields listed in initializer that are not in solr response" do
|
|
47
|
+
rendered.should_not include_text(@fname_3)
|
|
48
|
+
end
|
|
49
|
+
|
|
50
|
+
it "should display field labels from initializer and raw solr field names in the class" do
|
|
51
|
+
# labels
|
|
52
|
+
rendered.should include_text(@flabel_1)
|
|
53
|
+
rendered.should include_text(@flabel_4)
|
|
54
|
+
# classes
|
|
55
|
+
rendered.should include_text("blacklight-#{@fname_1}")
|
|
56
|
+
rendered.should include_text("blacklight-#{@fname_4}")
|
|
57
|
+
end
|
|
58
|
+
|
|
59
|
+
# this test probably belongs in a Cucumber feature
|
|
60
|
+
# it "should display fields in the order listed in the initializer" do
|
|
61
|
+
# pending
|
|
62
|
+
# end
|
|
63
|
+
|
|
64
|
+
it "should have values for displayed fields" do
|
|
65
|
+
rendered.should include_text("val_1")
|
|
66
|
+
rendered.should include_text("val_4")
|
|
67
|
+
rendered.should_not include_text("val_2")
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|