blacklight 3.1.2 → 3.2.0pre1
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/.gitignore +5 -2
- data/README.md +7 -2
- data/VERSION +1 -1
- data/app/assets/images/favicon.ico +0 -0
- data/app/assets/javascripts/blacklight/blacklight.js +23 -1
- data/app/assets/stylesheets/blacklight/_catalog.css.scss +369 -0
- data/app/assets/stylesheets/blacklight/_facets.css.scss +117 -0
- data/app/assets/stylesheets/blacklight/_folder.css.scss +38 -0
- data/app/assets/stylesheets/blacklight/_formatting.css.scss +164 -0
- data/app/assets/stylesheets/blacklight/_header.css.scss +36 -0
- data/app/assets/stylesheets/blacklight/_layout.css.scss +79 -0
- data/app/assets/stylesheets/blacklight/_print.css.scss +54 -0
- data/app/assets/stylesheets/blacklight/_search_history.css.scss +44 -0
- data/app/assets/stylesheets/blacklight/_susy_framework.css.scss +228 -0
- data/app/assets/stylesheets/blacklight/blacklight.css.scss +27 -0
- data/app/assets/stylesheets/blacklight/blacklight_defaults.css.scss +48 -0
- data/app/controllers/bookmarks_controller.rb +2 -1
- data/app/controllers/folder_controller.rb +4 -0
- data/app/controllers/saved_searches_controller.rb +4 -0
- data/app/controllers/search_history_controller.rb +4 -0
- data/app/helpers/blacklight/blacklight_helper_behavior.rb +64 -104
- data/app/helpers/blacklight/catalog_helper_behavior.rb +4 -4
- data/app/helpers/blacklight/facets_helper_behavior.rb +52 -5
- data/app/helpers/blacklight/render_constraints_helper_behavior.rb +14 -59
- data/app/helpers/blacklight/search_history_constraints_helper_behavior.rb +56 -0
- data/app/helpers/search_history_constraints_helper.rb +3 -0
- data/app/models/record_mailer.rb +1 -2
- data/app/views/_flash_msg.html.erb +4 -5
- data/app/views/_user_util_links.html.erb +3 -1
- data/app/views/bookmarks/index.html.erb +2 -2
- data/app/views/catalog/_bookmark_control.html.erb +6 -6
- data/app/views/catalog/_facet_layout.html.erb +4 -0
- data/app/views/catalog/_facet_limit.html.erb +20 -33
- data/app/views/catalog/_facets.html.erb +1 -5
- data/app/views/catalog/_folder_control.html.erb +5 -5
- data/app/views/catalog/_index_default.html.erb +1 -1
- data/app/views/catalog/_search_form.html.erb +4 -3
- data/app/views/catalog/_show_default.html.erb +1 -1
- data/app/views/catalog/_show_tools.html.erb +6 -6
- data/app/views/catalog/_sort_and_per_page.html.erb +1 -1
- data/app/views/catalog/index.atom.builder +2 -2
- data/app/views/catalog/index.rss.builder +1 -1
- data/app/views/catalog/opensearch.xml.builder +10 -0
- data/app/views/catalog/show.html.erb +1 -1
- data/app/views/folder/_tools.html.erb +4 -4
- data/app/views/layouts/blacklight.html.erb +25 -37
- data/app/views/record_mailer/email_record.text.erb +1 -1
- data/app/views/record_mailer/sms_record.text.erb +2 -2
- data/app/views/search_history/index.html.erb +1 -1
- data/blacklight.gemspec +11 -9
- data/lib/{generators/blacklight/templates/SolrMarc.jar → SolrMarc.jar} +0 -0
- data/lib/blacklight.rb +5 -3
- data/lib/blacklight/catalog.rb +3 -4
- data/lib/blacklight/configurable.rb +54 -39
- data/lib/blacklight/configuration.rb +126 -0
- data/lib/blacklight/configuration/fields.rb +142 -0
- data/lib/blacklight/configuration/search_field.rb +12 -0
- data/lib/blacklight/configuration/solr_field.rb +12 -0
- data/lib/blacklight/configuration/sort_field.rb +17 -0
- data/lib/blacklight/controller.rb +16 -14
- data/lib/blacklight/engine.rb +1 -1
- data/lib/blacklight/global_configurable.rb +46 -0
- data/lib/blacklight/search_fields.rb +21 -54
- data/lib/blacklight/solr/document.rb +13 -3
- data/lib/blacklight/solr_helper.rb +88 -52
- data/lib/blacklight/utils.rb +18 -0
- data/lib/generators/blacklight/assets_generator.rb +14 -20
- data/lib/generators/blacklight/blacklight_generator.rb +14 -6
- data/lib/generators/blacklight/jetty_generator.rb +1 -1
- data/lib/generators/blacklight/templates/assets/standard.css.scss +51 -0
- data/lib/generators/blacklight/templates/catalog_controller.rb +148 -0
- data/lib/generators/blacklight/templates/config/blacklight_config.rb +2 -239
- data/lib/generators/blacklight/templates/config/sass.rb +5 -0
- data/lib/generators/blacklight/templates/solr_conf/schema.xml +514 -164
- data/lib/generators/blacklight/templates/solr_conf/solrconfig.xml +1591 -323
- data/lib/generators/blacklight/templates/solr_document.rb +2 -0
- data/lib/railties/all_tests.rake +36 -3
- data/lib/railties/blacklight_cucumber.rake +6 -4
- data/lib/railties/blacklight_rspec.rake +5 -4
- data/test_support/bin/run-tests.sh +2 -13
- data/test_support/bin/test.sh +30 -23
- data/test_support/features/did_you_mean.feature +14 -13
- data/test_support/features/step_definitions/saved_searches_steps.rb +1 -1
- data/test_support/features/step_definitions/search_steps.rb +4 -4
- data/test_support/spec/controllers/application_controller_spec.rb +3 -13
- data/test_support/spec/controllers/catalog_controller_spec.rb +102 -24
- data/test_support/spec/controllers/folder_controller_spec.rb +7 -1
- data/test_support/spec/helpers/blacklight_helper_spec.rb +45 -34
- data/test_support/spec/helpers/facets_helper_spec.rb +68 -0
- data/test_support/spec/helpers/html_head_helper_spec.rb +37 -0
- data/test_support/spec/helpers/{render_constraints_helper_spec.rb → search_history_constraints_helper_spec.rb} +26 -7
- data/test_support/spec/lib/blacklight_configurable_spec.rb +92 -0
- data/test_support/spec/lib/blacklight_configuration_spec.rb +295 -0
- data/test_support/spec/lib/{configurable_spec.rb → global_configurable_spec.rb} +2 -2
- data/test_support/spec/lib/search_fields_spec.rb +26 -29
- data/test_support/spec/{helpers → lib}/solr_helper_spec.rb +268 -287
- data/test_support/spec/lib/tasks/solr_marc_task_spec.rb +1 -1
- data/test_support/spec/lib/utils_spec.rb +58 -0
- data/test_support/spec/models/solr_docment_spec.rb +4 -8
- data/test_support/spec/views/catalog/_facets.html.erb_spec.rb +27 -170
- data/test_support/spec/views/catalog/_index_default.erb_spec.rb +38 -20
- data/test_support/spec/views/catalog/_show_default.erb_spec.rb +38 -19
- data/test_support/spec/views/catalog/index.atom.builder_spec.rb +19 -1
- metadata +148 -145
- data/app/assets/stylesheets/blacklight/blacklight.css +0 -493
- data/app/assets/stylesheets/yui.css +0 -31
- data/app/views/catalog/opensearch.xml.erb +0 -11
- data/doc/Atom-Responses.md +0 -90
- data/doc/CUSTOMIZING.md +0 -121
- data/doc/Extending-blacklight-with-the-document-extension-framework.md +0 -1
- data/doc/Extending-or-Modifying-Blacklight-Search-Behavior.md +0 -131
- data/doc/Features.md +0 -147
- data/doc/Integration-with-Rails-Footnotes.md +0 -20
- data/doc/Pagination.md +0 -38
- data/doc/Quickstart.md +0 -97
- data/doc/Upgrading-Guide.md +0 -98
- data/doc/User-Authentication.md +0 -54
- data/doc/Using-a-custom-solr-uniquekey-field.md +0 -36
- data/lib/blacklight/comma_link_renderer.rb +0 -28
- data/lib/railties/jetty_solr_server.rb +0 -108
- data/test_support/spec/views/catalog/show.html.erb_spec.rb +0 -101
data/lib/railties/all_tests.rake
CHANGED
|
@@ -5,13 +5,47 @@ namespace :blacklight do
|
|
|
5
5
|
require 'rspec/core/rake_task'
|
|
6
6
|
|
|
7
7
|
desc "Run Blacklight cucumber and rspec, with test solr"
|
|
8
|
-
task :all_tests =>
|
|
8
|
+
task :all_tests => :hudson
|
|
9
|
+
|
|
10
|
+
desc "Run Blacklight cucumber and rspec, with test solr"
|
|
11
|
+
task :hudson do
|
|
12
|
+
solr_yml_path = Blacklight.locate_path("config", "solr.yml")
|
|
13
|
+
jetty_path = if ( File.exists?( solr_yml_path ))
|
|
14
|
+
solr_config = YAML::load(File.open(solr_yml_path))
|
|
15
|
+
solr_config["test"]["jetty_path"] if solr_config["test"]
|
|
16
|
+
end
|
|
17
|
+
raise Exception.new("Can't find jetty path to start test jetty. Expect a jetty_path key in config/solr.yml for test environment.") unless jetty_path
|
|
18
|
+
|
|
19
|
+
error = Jettywrapper.wrap(
|
|
20
|
+
:jetty_home => File.expand_path(jetty_path, Rails.root),
|
|
21
|
+
:sleep_after_start => 2) do
|
|
22
|
+
Rake::Task["blacklight:spec"].invoke
|
|
23
|
+
Rake::Task["blacklight:cucumber"].invoke
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
raise "test failures: #{error}" if error
|
|
27
|
+
end
|
|
9
28
|
|
|
10
29
|
namespace :all_tests do
|
|
30
|
+
task :rcov do
|
|
11
31
|
desc "Run Blacklight rspec and cucumber tests with rcov"
|
|
32
|
+
solr_yml_path = Blacklight.locate_path("config", "solr.yml")
|
|
33
|
+
jetty_path = if ( File.exists?( solr_yml_path ))
|
|
34
|
+
solr_config = YAML::load(File.open(solr_yml_path))
|
|
35
|
+
solr_config["test"]["jetty_path"] if solr_config["test"]
|
|
36
|
+
end
|
|
37
|
+
raise Exception.new("Can't find jetty path to start test jetty. Expect a jetty_path key in config/solr.yml for test environment.") unless jetty_path
|
|
38
|
+
|
|
12
39
|
rm "blacklight-coverage.data" if File.exist?("blacklight-coverage.data")
|
|
13
|
-
|
|
40
|
+
error = Jettywrapper.wrap(
|
|
41
|
+
:jetty_home => File.expand_path(jetty_path, Rails.root),
|
|
42
|
+
:sleep_after_start => 2) do
|
|
43
|
+
Rake::Task["blacklight:spec:rcov"].invoke
|
|
44
|
+
Rake::Task["blacklight:cucumber:rcov"].invoke
|
|
45
|
+
end
|
|
46
|
+
raise "test failures: #{error}" if error
|
|
14
47
|
end
|
|
48
|
+
end
|
|
15
49
|
|
|
16
50
|
rescue LoadError
|
|
17
51
|
desc "Not available! (cucumber and rspec not avail)"
|
|
@@ -20,4 +54,3 @@ namespace :blacklight do
|
|
|
20
54
|
end
|
|
21
55
|
end
|
|
22
56
|
end
|
|
23
|
-
|
|
@@ -78,25 +78,27 @@ begin
|
|
|
78
78
|
# when starting solr test server during functional tests use:
|
|
79
79
|
#
|
|
80
80
|
# rake SOLR_CONSOLE=true
|
|
81
|
-
require File.expand_path('../jetty_solr_server.rb', __FILE__)
|
|
82
81
|
desc "blacklight:cucumber with jetty/solr launch"
|
|
83
82
|
task :with_solr do
|
|
83
|
+
require 'jettywrapper'
|
|
84
84
|
# wrap tests with a test-specific Solr server
|
|
85
85
|
# Need to look up where the test jetty is located
|
|
86
86
|
# from solr.yml, we don't hardcode it anymore.
|
|
87
87
|
|
|
88
|
-
solr_yml_path = locate_path("config", "solr.yml")
|
|
88
|
+
solr_yml_path = Blacklight.locate_path("config", "solr.yml")
|
|
89
89
|
jetty_path = if ( File.exists?( solr_yml_path ))
|
|
90
90
|
solr_config = YAML::load(File.open(solr_yml_path))
|
|
91
91
|
solr_config["test"]["jetty_path"] if solr_config["test"]
|
|
92
92
|
end
|
|
93
93
|
raise Exception.new("Can't find jetty path to start test jetty. Expect a jetty_path key in config/solr.yml for test environment.") unless jetty_path
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
error = Jettywrapper.wrap(
|
|
96
96
|
:jetty_home => File.expand_path(jetty_path, Rails.root),
|
|
97
|
-
:sleep_after_start => 2)
|
|
97
|
+
:sleep_after_start => 2) do
|
|
98
98
|
Rake::Task["blacklight:cucumber"].invoke
|
|
99
99
|
end
|
|
100
|
+
|
|
101
|
+
raise "test failures: #{error}" if error
|
|
100
102
|
end
|
|
101
103
|
|
|
102
104
|
end
|
|
@@ -72,14 +72,14 @@ begin
|
|
|
72
72
|
# when starting solr test server during functional tests use:
|
|
73
73
|
#
|
|
74
74
|
# rake SOLR_CONSOLE=true
|
|
75
|
-
require File.expand_path('../jetty_solr_server.rb', __FILE__)
|
|
76
75
|
desc "blacklight:solr with jetty/solr launch"
|
|
77
76
|
task :with_solr do
|
|
77
|
+
require 'jettywrapper'
|
|
78
78
|
# wrap tests with a test-specific Solr server
|
|
79
79
|
# Need to look up where the test jetty is located
|
|
80
80
|
# from solr.yml, we don't hardcode it anymore.
|
|
81
81
|
|
|
82
|
-
solr_yml_path = locate_path("config", "solr.yml")
|
|
82
|
+
solr_yml_path = Blacklight.locate_path("config", "solr.yml")
|
|
83
83
|
jetty_path = if ( File.exists?( solr_yml_path ))
|
|
84
84
|
solr_config = YAML::load(File.open(solr_yml_path))
|
|
85
85
|
solr_config["test"]["jetty_path"] if solr_config["test"]
|
|
@@ -88,11 +88,12 @@ begin
|
|
|
88
88
|
|
|
89
89
|
|
|
90
90
|
# wrap tests with a test-specific Solr server
|
|
91
|
-
|
|
91
|
+
error = Jettywrapper.wrap(
|
|
92
92
|
:jetty_home => File.expand_path(jetty_path, Rails.root),
|
|
93
|
-
:sleep_after_start => 2)
|
|
93
|
+
:sleep_after_start => 2) do
|
|
94
94
|
Rake::Task["blacklight:spec"].invoke
|
|
95
95
|
end
|
|
96
|
+
raise "test failures: #{error}" if error
|
|
96
97
|
end
|
|
97
98
|
|
|
98
99
|
|
|
@@ -18,11 +18,6 @@ check_errs()
|
|
|
18
18
|
if [ "${1}" -ne "0" ]; then
|
|
19
19
|
echo "ERROR # ${1} : ${2}"
|
|
20
20
|
|
|
21
|
-
# Attempt to shut down jetty, if set.
|
|
22
|
-
if [ $jetty_pid ]
|
|
23
|
-
then
|
|
24
|
-
kill $jetty_pid
|
|
25
|
-
fi
|
|
26
21
|
benchmark
|
|
27
22
|
exit 1
|
|
28
23
|
fi
|
|
@@ -53,12 +48,6 @@ rvm use "$@" --create
|
|
|
53
48
|
check_errs $? "rvm failed. please run 'rvm install $@', and then re-run these tests."
|
|
54
49
|
|
|
55
50
|
cd tmp/test_app
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
jetty_pid=$!
|
|
59
|
-
cd ..
|
|
60
|
-
bundle exec rake blacklight:spec
|
|
61
|
-
check_errs $? "Rpec Tests failed."
|
|
62
|
-
bundle exec rake blacklight:cucumber
|
|
63
|
-
check_errs $? "Cucumber Tests failed."
|
|
51
|
+
bundle exec rake blacklight:hudson
|
|
52
|
+
check_errs $? "Tests failed."
|
|
64
53
|
benchmark
|
data/test_support/bin/test.sh
CHANGED
|
@@ -17,12 +17,6 @@ check_errs()
|
|
|
17
17
|
# Para. 2 is text to display on failure.
|
|
18
18
|
if [ "${1}" -ne "0" ]; then
|
|
19
19
|
echo "ERROR # ${1} : ${2}"
|
|
20
|
-
|
|
21
|
-
# Attempt to shut down jetty, if set.
|
|
22
|
-
if [ $jetty_pid ]
|
|
23
|
-
then
|
|
24
|
-
kill $jetty_pid
|
|
25
|
-
fi
|
|
26
20
|
benchmark
|
|
27
21
|
exit 1
|
|
28
22
|
fi
|
|
@@ -57,7 +51,7 @@ fi
|
|
|
57
51
|
rvm use "$@" --create
|
|
58
52
|
check_errs $? "rvm failed. please run 'rvm install $@', and then re-run these tests."
|
|
59
53
|
|
|
60
|
-
if ! gem query -n rails -v "
|
|
54
|
+
if ! gem query -n rails -v ">=3.1.1" --installed > /dev/null; then
|
|
61
55
|
gem install --no-rdoc --no-ri 'rails'
|
|
62
56
|
fi
|
|
63
57
|
|
|
@@ -69,12 +63,13 @@ rails new test_app
|
|
|
69
63
|
cd test_app
|
|
70
64
|
echo "
|
|
71
65
|
source 'http://rubygems.org'
|
|
72
|
-
|
|
73
|
-
gem 'rails', '
|
|
66
|
+
gem 'rack', '1.3.3'
|
|
67
|
+
gem 'rails', '~> 3.1.1'
|
|
74
68
|
platforms :jruby do
|
|
75
69
|
gem 'jruby-openssl'
|
|
76
70
|
gem 'activerecord-jdbcsqlite3-adapter'
|
|
77
71
|
gem 'jdbc-sqlite3'
|
|
72
|
+
gem 'mediashelf-loggable', '>= 0.4.8'
|
|
78
73
|
end
|
|
79
74
|
platforms :ruby do
|
|
80
75
|
gem 'sqlite3-ruby', :require => 'sqlite3'
|
|
@@ -82,6 +77,23 @@ end
|
|
|
82
77
|
gem 'blacklight', :path => '../../'
|
|
83
78
|
gem 'jquery-rails'
|
|
84
79
|
|
|
80
|
+
group :assets do
|
|
81
|
+
gem 'sass-rails', '~> 3.1.1'
|
|
82
|
+
gem 'coffee-rails', '~> 3.1.1'
|
|
83
|
+
gem 'uglifier'
|
|
84
|
+
gem 'compass', '0.12.alpha.2'
|
|
85
|
+
|
|
86
|
+
platforms :ruby do
|
|
87
|
+
gem 'execjs'
|
|
88
|
+
gem 'therubyracer'
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
platforms :jruby do
|
|
92
|
+
gem 'therubyrhino'
|
|
93
|
+
end
|
|
94
|
+
end
|
|
95
|
+
|
|
96
|
+
|
|
85
97
|
# For testing
|
|
86
98
|
group :development, :test do
|
|
87
99
|
gem 'rspec'
|
|
@@ -91,13 +103,14 @@ group :development, :test do
|
|
|
91
103
|
gem 'database_cleaner'
|
|
92
104
|
gem 'capybara'
|
|
93
105
|
gem 'webrat'
|
|
94
|
-
gem 'aruba'
|
|
95
106
|
end
|
|
96
107
|
|
|
97
|
-
gem '
|
|
108
|
+
gem 'jettywrapper', '>= 1.2.0'
|
|
109
|
+
gem \"devise\"
|
|
98
110
|
" > Gemfile
|
|
99
111
|
|
|
100
112
|
bundle install --local &> /dev/null
|
|
113
|
+
bundle update
|
|
101
114
|
# If a local install fails, try a full install.
|
|
102
115
|
if [ "$?" -ne "0" ]
|
|
103
116
|
then
|
|
@@ -106,25 +119,19 @@ fi
|
|
|
106
119
|
check_errs $? "Bundle install failed."
|
|
107
120
|
rails generate blacklight -d
|
|
108
121
|
check_errs $? "Blacklight generator failed"
|
|
109
|
-
rake db:migrate
|
|
122
|
+
bundle exec rake db:migrate
|
|
110
123
|
check_errs $? "Rake Migration failed"
|
|
111
124
|
rails g cucumber:install &> /dev/null
|
|
112
|
-
jetty_zip="/tmp/
|
|
125
|
+
jetty_zip="/tmp/bl_jetty_3_5_0.zip"
|
|
113
126
|
if [ ! -f $jetty_zip ]
|
|
114
127
|
then
|
|
115
|
-
curl -L https://github.com/projectblacklight/blacklight-jetty/zipball/
|
|
128
|
+
curl -L https://github.com/projectblacklight/blacklight-jetty/zipball/v3.5.0 -o $jetty_zip
|
|
116
129
|
check_errs $? "Jetty file does not exist, and cannot be downloaded."
|
|
117
130
|
fi
|
|
118
131
|
rails g blacklight:jetty test_jetty -e test -d $jetty_zip
|
|
119
132
|
check_errs $? "Jetty setup failed."
|
|
120
133
|
rm public/index.html
|
|
121
|
-
rake solr:marc:index_test_data RAILS_ENV=test
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
jetty_pid=$!
|
|
125
|
-
cd ..
|
|
126
|
-
bundle exec rake blacklight:spec
|
|
127
|
-
check_errs $? "Rpec Tests failed."
|
|
128
|
-
bundle exec rake blacklight:cucumber
|
|
129
|
-
check_errs $? "Cucumber Tests failed."
|
|
134
|
+
bundle exec rake solr:marc:index_test_data RAILS_ENV=test
|
|
135
|
+
bundle exec rake blacklight:hudson
|
|
136
|
+
check_errs $? "Tests failed."
|
|
130
137
|
benchmark
|
|
@@ -96,19 +96,20 @@ Feature: Did You Mean
|
|
|
96
96
|
And I press "search"
|
|
97
97
|
Then I should not see "Did you mean"
|
|
98
98
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
And I
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
And I
|
|
111
|
-
|
|
99
|
+
## can't get these to work with solr 3.4
|
|
100
|
+
# Scenario: Exact Threshold number of results for spelling suggestion
|
|
101
|
+
# Given I am on the home page
|
|
102
|
+
# # polit gives 5 results in 30 record demo index - 5 is default cutoff
|
|
103
|
+
# And I fill in "q" with "polit"
|
|
104
|
+
# And I press "search"
|
|
105
|
+
# Then I should see "Did you mean"
|
|
106
|
+
#
|
|
107
|
+
# Scenario: Same number of results as spelling suggestion
|
|
108
|
+
# Given I am on the home page
|
|
109
|
+
# # den gives 1 result in 30 record demo index - suggestion don is 1 result also
|
|
110
|
+
# And I fill in "q" with "den"
|
|
111
|
+
# And I press "search"
|
|
112
|
+
# Then I should not see "Did you mean"
|
|
112
113
|
|
|
113
114
|
Scenario: Multiple terms should have individual links, not single query link
|
|
114
115
|
Given I am on the home page
|
|
@@ -9,7 +9,7 @@ Given /^I am logged in as "([^\"]*)"$/ do |login|
|
|
|
9
9
|
fill_in("user_password", :with => "password")
|
|
10
10
|
click_button("Sign in")
|
|
11
11
|
# response.body.should =~ /Logged/m
|
|
12
|
-
|
|
12
|
+
step 'I should see "Log Out"'
|
|
13
13
|
end
|
|
14
14
|
|
|
15
15
|
Given /^"([^\"]*)" has saved a search with term "([^\"]*)"$/ do |user, term|
|
|
@@ -28,9 +28,9 @@ Given /^the application is configured to have searchable fields "([^\"]*)" with
|
|
|
28
28
|
labels = fields.split(", ")
|
|
29
29
|
values = values.split(", ")
|
|
30
30
|
combined = labels.zip(values)
|
|
31
|
-
|
|
31
|
+
CatalogController.blacklight_config[:search_fields] = []
|
|
32
32
|
combined.each do |pair|
|
|
33
|
-
|
|
33
|
+
CatalogController.blacklight_config[:search_fields] << pair
|
|
34
34
|
end
|
|
35
35
|
end
|
|
36
36
|
|
|
@@ -56,9 +56,9 @@ Given /^the application is configured to have sort fields "([^\"]*)" with values
|
|
|
56
56
|
labels = fields.split(", ")
|
|
57
57
|
values = values.split(", ")
|
|
58
58
|
combined = labels.zip(values)
|
|
59
|
-
|
|
59
|
+
CatalogController.blacklight_config[:sort_fields] = []
|
|
60
60
|
combined.each do |pair|
|
|
61
|
-
|
|
61
|
+
CatalogController.blacklight_config[:sort_fields] << pair
|
|
62
62
|
end
|
|
63
63
|
end
|
|
64
64
|
|
|
@@ -7,21 +7,11 @@ describe ApplicationController do
|
|
|
7
7
|
|
|
8
8
|
describe "#default_html_head" do
|
|
9
9
|
it "should setup js and css defaults" do
|
|
10
|
-
|
|
11
|
-
controller.should_receive(:use_asset_pipeline?).any_number_of_times.and_return(false)
|
|
12
10
|
controller.send(:default_html_head)
|
|
13
|
-
controller.javascript_includes.should include(["jquery-1.4.2.min.js", "jquery-ui-1.8.1.custom.min.js", "blacklight/blacklight"])#find do |item|
|
|
14
|
-
# item == ["jquery-1.4.2.min.js", "jquery-ui-1.7.2.custom.min.js", "blacklight", "application", "accordion", "lightbox", {:plugin=>:blacklight}]
|
|
15
|
-
#end
|
|
16
|
-
|
|
17
|
-
controller.stylesheet_links.should include(["yui", "jquery/ui-lightness/jquery-ui-1.8.1.custom.css", "blacklight/blacklight", {:media=>"all"}])
|
|
18
|
-
end
|
|
19
11
|
|
|
20
|
-
|
|
21
|
-
controller.
|
|
22
|
-
controller.
|
|
23
|
-
controller.javascript_includes.should include(["application"])
|
|
24
|
-
controller.stylesheet_links.should include(["application"])
|
|
12
|
+
# by default, these should be empty, but left in for backwards compatibility
|
|
13
|
+
controller.javascript_includes.should be_empty
|
|
14
|
+
controller.stylesheet_links.should be_empty
|
|
25
15
|
end
|
|
26
16
|
end
|
|
27
17
|
end
|
|
@@ -47,6 +47,18 @@ describe CatalogController do
|
|
|
47
47
|
end
|
|
48
48
|
end
|
|
49
49
|
|
|
50
|
+
describe "catalog_url for SolrDocument", :test => true do
|
|
51
|
+
it "should route correctly" do
|
|
52
|
+
{ :get => catalog_url(SolrDocument.new(:id => 'asdf')) }.should route_to(:controller => 'catalog', :action => 'show', :id => 'asdf')
|
|
53
|
+
end
|
|
54
|
+
|
|
55
|
+
it "should escape solr document ids" do
|
|
56
|
+
catalog_path(SolrDocument.new(:id => 'http://example.com')).should == "/catalog/http%3A%2F%2Fexample%2Ecom"
|
|
57
|
+
{ :get => catalog_url(SolrDocument.new(:id => 'http://example.com'))}.should route_to(:controller => 'catalog', :action => 'show', :id => 'http://example.com')
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
end
|
|
61
|
+
|
|
50
62
|
|
|
51
63
|
|
|
52
64
|
# INDEX ACTION
|
|
@@ -66,38 +78,39 @@ describe CatalogController do
|
|
|
66
78
|
end
|
|
67
79
|
|
|
68
80
|
it "should have no search history if no search criteria" do
|
|
81
|
+
controller.should_receive(:get_search_results)
|
|
69
82
|
session[:history] = []
|
|
70
83
|
get :index
|
|
71
84
|
session[:history].length.should == 0
|
|
72
85
|
end
|
|
73
86
|
|
|
74
87
|
# check each user manipulated parameter
|
|
75
|
-
it "should have docs and facets for query with results" do
|
|
88
|
+
it "should have docs and facets for query with results", :integration => true do
|
|
76
89
|
get :index, :q => @user_query
|
|
77
90
|
assigns_response.docs.size.should > 1
|
|
78
91
|
assert_facets_have_values(assigns_response.facets)
|
|
79
92
|
end
|
|
80
|
-
it "should have docs and facets for existing facet value" do
|
|
93
|
+
it "should have docs and facets for existing facet value", :integration => true do
|
|
81
94
|
get :index, :f => @facet_query
|
|
82
95
|
assigns_response.docs.size.should > 1
|
|
83
96
|
assert_facets_have_values(assigns_response.facets)
|
|
84
97
|
end
|
|
85
|
-
it "should have docs and facets for non-default results per page" do
|
|
98
|
+
it "should have docs and facets for non-default results per page", :integration => true do
|
|
86
99
|
num_per_page = 7
|
|
87
100
|
get :index, :per_page => num_per_page
|
|
88
101
|
assigns_response.docs.size.should == num_per_page
|
|
89
102
|
assert_facets_have_values(assigns_response.facets)
|
|
90
103
|
end
|
|
91
104
|
|
|
92
|
-
it "should have docs and facets for second page" do
|
|
105
|
+
it "should have docs and facets for second page", :integration => true do
|
|
93
106
|
page = 2
|
|
94
107
|
get :index, :page => page
|
|
95
108
|
assigns_response.docs.size.should > 1
|
|
96
|
-
assigns_response.params[:start].to_i.should == (page-1) *
|
|
109
|
+
assigns_response.params[:start].to_i.should == (page-1) * @controller.blacklight_config[:default_solr_params][:rows]
|
|
97
110
|
assert_facets_have_values(assigns_response.facets)
|
|
98
111
|
end
|
|
99
112
|
|
|
100
|
-
it "should have no docs or facet values for query without results" do
|
|
113
|
+
it "should have no docs or facet values for query without results", :integration => true do
|
|
101
114
|
get :index, :q => @no_docs_query
|
|
102
115
|
|
|
103
116
|
assigns_response.docs.size.should == 0
|
|
@@ -106,12 +119,15 @@ describe CatalogController do
|
|
|
106
119
|
end
|
|
107
120
|
end
|
|
108
121
|
|
|
109
|
-
it "should have a spelling suggestion for an appropriately poor query" do
|
|
122
|
+
it "should have a spelling suggestion for an appropriately poor query", :integration => true do
|
|
110
123
|
get :index, :q => 'boo'
|
|
111
124
|
assigns_response.spelling.words.should_not be_nil
|
|
112
125
|
end
|
|
113
126
|
|
|
114
127
|
describe "session" do
|
|
128
|
+
before do
|
|
129
|
+
controller.stub(:get_search_results)
|
|
130
|
+
end
|
|
115
131
|
it "should include :search key with hash" do
|
|
116
132
|
get :index
|
|
117
133
|
session[:search].should_not be_nil
|
|
@@ -150,39 +166,30 @@ describe CatalogController do
|
|
|
150
166
|
end
|
|
151
167
|
end
|
|
152
168
|
|
|
153
|
-
describe "with index action with arbitrary key" do
|
|
154
|
-
before(:each) do
|
|
155
|
-
session[:history] = []
|
|
156
|
-
get :index, :arbitrary_key_from_plugin => "value"
|
|
157
|
-
end
|
|
158
|
-
it "should save search history" do
|
|
159
|
-
session[:history].length.should_not == 0
|
|
160
|
-
end
|
|
161
|
-
end
|
|
162
|
-
|
|
163
169
|
# check with no user manipulation
|
|
164
170
|
describe "for default query" do
|
|
165
|
-
it "should get documents when no query" do
|
|
171
|
+
it "should get documents when no query", :integration => true do
|
|
166
172
|
get :index
|
|
167
173
|
assigns_response.docs.size.should > 1
|
|
168
174
|
end
|
|
169
|
-
it "should get facets when no query" do
|
|
175
|
+
it "should get facets when no query", :integration => true do
|
|
170
176
|
get :index
|
|
171
177
|
assert_facets_have_values(assigns_response.facets)
|
|
172
178
|
end
|
|
173
179
|
end
|
|
174
180
|
|
|
175
|
-
it "should get rss feed" do
|
|
181
|
+
it "should get rss feed", :integration => true do
|
|
176
182
|
get :index, :format => 'rss'
|
|
177
183
|
response.should be_success
|
|
178
184
|
end
|
|
179
185
|
|
|
180
186
|
it "should render index.html.erb" do
|
|
187
|
+
controller.stub(:get_search_results)
|
|
181
188
|
get :index
|
|
182
189
|
response.should render_template(:index)
|
|
183
190
|
end
|
|
184
191
|
# NOTE: status code is always 200 in isolation mode ...
|
|
185
|
-
it "HTTP status code for GET should be 200" do
|
|
192
|
+
it "HTTP status code for GET should be 200", :integration => true do
|
|
186
193
|
get :index
|
|
187
194
|
response.should be_success
|
|
188
195
|
end
|
|
@@ -208,10 +215,19 @@ describe CatalogController do
|
|
|
208
215
|
|
|
209
216
|
doc_id = '2007020969'
|
|
210
217
|
|
|
211
|
-
it "should get document" do
|
|
218
|
+
it "should get document", :integration => true do
|
|
212
219
|
get :show, :id => doc_id
|
|
213
220
|
assigns[:document].should_not be_nil
|
|
214
221
|
end
|
|
222
|
+
|
|
223
|
+
describe "previous/next documents" do
|
|
224
|
+
before do
|
|
225
|
+
@mock_response = mock()
|
|
226
|
+
@mock_document = mock()
|
|
227
|
+
@mock_document.stub(:export_formats => {})
|
|
228
|
+
controller.stub(:get_solr_response_for_doc_id => [@mock_response, @mock_document],
|
|
229
|
+
:get_single_doc_via_search => @mock_document)
|
|
230
|
+
end
|
|
215
231
|
it "should set previous document if counter present in session" do
|
|
216
232
|
session[:search] = {:q => "", :counter => 2}
|
|
217
233
|
get :show, :id => doc_id
|
|
@@ -239,22 +255,36 @@ describe CatalogController do
|
|
|
239
255
|
assigns[:next_document].should_not be_nil
|
|
240
256
|
end
|
|
241
257
|
it "should not set next document if counter is >= number of docs" do
|
|
258
|
+
controller.stub(:get_single_doc_via_search => nil)
|
|
242
259
|
session[:search] = {:counter => 66666666}
|
|
243
260
|
get :show, :id => doc_id
|
|
244
261
|
assigns[:next_document].should be_nil
|
|
245
262
|
end
|
|
263
|
+
end
|
|
246
264
|
|
|
247
265
|
# NOTE: status code is always 200 in isolation mode ...
|
|
248
|
-
it "HTTP status code for GET should be 200" do
|
|
266
|
+
it "HTTP status code for GET should be 200", :integration => true do
|
|
249
267
|
get :show, :id => doc_id
|
|
250
268
|
response.should be_success
|
|
251
269
|
end
|
|
252
270
|
it "should render show.html.erb" do
|
|
271
|
+
@mock_response = mock()
|
|
272
|
+
@mock_document = mock()
|
|
273
|
+
@mock_document.stub(:export_formats => {})
|
|
274
|
+
controller.stub(:get_solr_response_for_doc_id => [@mock_response, @mock_document],
|
|
275
|
+
:get_single_doc_via_search => @mock_document)
|
|
253
276
|
get :show, :id => doc_id
|
|
254
277
|
response.should render_template(:show)
|
|
255
278
|
end
|
|
256
279
|
|
|
257
280
|
describe "@document" do
|
|
281
|
+
before do
|
|
282
|
+
@mock_response = mock()
|
|
283
|
+
@mock_response.stub(:docs => [{ :id => 'my_fake_doc' }])
|
|
284
|
+
@mock_document = mock()
|
|
285
|
+
controller.stub(:find => @mock_response,
|
|
286
|
+
:get_single_doc_via_search => @mock_document)
|
|
287
|
+
end
|
|
258
288
|
before(:each) do
|
|
259
289
|
get :show, :id => doc_id
|
|
260
290
|
@document = assigns[:document]
|
|
@@ -275,6 +305,14 @@ describe CatalogController do
|
|
|
275
305
|
"mock_export"
|
|
276
306
|
end
|
|
277
307
|
end
|
|
308
|
+
before do
|
|
309
|
+
@mock_response = mock()
|
|
310
|
+
@mock_document = mock()
|
|
311
|
+
@mock_response.stub(:docs => [{ :id => 'my_fake_doc' }])
|
|
312
|
+
@mock_document = mock()
|
|
313
|
+
controller.stub(:find => @mock_response,
|
|
314
|
+
:get_single_doc_via_search => @mock_document)
|
|
315
|
+
end
|
|
278
316
|
|
|
279
317
|
before(:each) do
|
|
280
318
|
|
|
@@ -302,8 +340,15 @@ describe CatalogController do
|
|
|
302
340
|
|
|
303
341
|
end # describe show action
|
|
304
342
|
|
|
305
|
-
|
|
306
343
|
describe "opensearch" do
|
|
344
|
+
before do
|
|
345
|
+
@mock_response = mock()
|
|
346
|
+
@mock_document = mock()
|
|
347
|
+
@mock_response.stub(:docs => [{ :id => 'my_fake_doc' }, { :id => 'my_other_doc'}])
|
|
348
|
+
@mock_document = mock()
|
|
349
|
+
controller.stub(:find => @mock_response,
|
|
350
|
+
:get_single_doc_via_search => @mock_document)
|
|
351
|
+
end
|
|
307
352
|
it "should return an opensearch description" do
|
|
308
353
|
get :opensearch, :format => 'xml'
|
|
309
354
|
response.should be_success
|
|
@@ -316,6 +361,14 @@ describe CatalogController do
|
|
|
316
361
|
#=end
|
|
317
362
|
describe "email/sms" do
|
|
318
363
|
doc_id = '2007020969'
|
|
364
|
+
before do
|
|
365
|
+
@mock_response = mock()
|
|
366
|
+
@mock_document = mock()
|
|
367
|
+
@mock_response.stub(:docs => [{ :id => 'my_fake_doc' }, { :id => 'my_other_doc'}])
|
|
368
|
+
@mock_document = mock()
|
|
369
|
+
controller.stub(:find => @mock_response,
|
|
370
|
+
:get_single_doc_via_search => @mock_document)
|
|
371
|
+
end
|
|
319
372
|
before(:each) do
|
|
320
373
|
request.env["HTTP_REFERER"] = "/catalog/#{doc_id}"
|
|
321
374
|
SolrDocument.use_extension( Blacklight::Solr::Document::Email )
|
|
@@ -382,6 +435,12 @@ describe CatalogController do
|
|
|
382
435
|
|
|
383
436
|
describe "errors" do
|
|
384
437
|
it "should return status 404 for a record that doesn't exist" do
|
|
438
|
+
@mock_response = mock()
|
|
439
|
+
@mock_document = mock()
|
|
440
|
+
@mock_response.stub(:docs => [])
|
|
441
|
+
@mock_document = mock()
|
|
442
|
+
controller.stub(:find => @mock_response,
|
|
443
|
+
:get_single_doc_via_search => @mock_document)
|
|
385
444
|
get :show, :id=>"987654321"
|
|
386
445
|
response.redirect_url.should == root_url
|
|
387
446
|
request.flash[:notice].should == "Sorry, you have requested a record that doesn't exist."
|
|
@@ -389,6 +448,7 @@ describe CatalogController do
|
|
|
389
448
|
response.status.should == 404
|
|
390
449
|
end
|
|
391
450
|
it "should return a status 500 for a bad search" do
|
|
451
|
+
controller.stub(:get_search_results) { |*args| raise RSolr::Error::Http.new(nil, nil) }
|
|
392
452
|
get :index, :q=>"+"
|
|
393
453
|
response.redirect_url.should == root_url
|
|
394
454
|
request.flash[:notice].should == "Sorry, I don't understand your search."
|
|
@@ -398,6 +458,24 @@ describe CatalogController do
|
|
|
398
458
|
|
|
399
459
|
end
|
|
400
460
|
|
|
461
|
+
context "without a user authentication provider" do
|
|
462
|
+
render_views
|
|
463
|
+
|
|
464
|
+
before do
|
|
465
|
+
controller.stub(:has_user_authentication_provider?) { false }
|
|
466
|
+
@mock_response = mock()
|
|
467
|
+
@mock_document = mock()
|
|
468
|
+
@mock_response.stub(:docs => [], :total => 1, :facets => [], :facet_by_field_name => nil)
|
|
469
|
+
@mock_document = mock()
|
|
470
|
+
controller.stub(:find => @mock_response,
|
|
471
|
+
:get_single_doc_via_search => @mock_document)
|
|
472
|
+
end
|
|
473
|
+
|
|
474
|
+
it "should not show user util links" do
|
|
475
|
+
get :index
|
|
476
|
+
response.body.should_not =~ /Login/
|
|
477
|
+
end
|
|
478
|
+
end
|
|
401
479
|
end
|
|
402
480
|
|
|
403
481
|
|