diff --git a/.circleci/config.yml b/.circleci/config.yml index 049d1487..019eb494 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -95,7 +95,7 @@ jobs: name: "Update Node.js and npm" command: | curl -sSL "https://nodejs.org/dist/v16.13.1/node-v16.13.1-linux-x64.tar.xz" | sudo tar --strip-components=2 -xJ -C /usr/local/bin/ node-v16.13.1-linux-x64/bin/node - curl https://npmjs.com/install.sh | sudo bash + curl -L https://npmjs.com/install.sh | sudo bash - run: name: "Bundle" command: | diff --git a/.gitignore b/.gitignore index c054d1a7..487d2d61 100644 --- a/.gitignore +++ b/.gitignore @@ -11,6 +11,10 @@ vendor/bundle/**/* /blackcat_test /psulcat_dev /psulcat_test +/psulcat_test-shm +/psulcat_test-wal +/psulcat_dev-shm +/psulcat_dev-wal # Ignore all logfiles and tempfiles. /log/* diff --git a/.rubocop.yml b/.rubocop.yml index fdf4d8e6..a8d78e06 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -36,6 +36,7 @@ Layout/LineLength: # The catalog controller is just one giant block for config. - 'app/controllers/catalog_controller.rb' - 'spec/controllers/catalog_controller_spec.rb' + - 'app/components/blacklight/advanced_search_form_component.rb' Lint/MissingSuper: Exclude: @@ -43,6 +44,10 @@ Lint/MissingSuper: - 'app/components/external_links/*' - 'app/models/concerns/null_object_pattern.rb' +Metrics/CyclomaticComplexity: + Exclude: + - 'app/components/psul_search_bar_component.rb' + Rails/ContentTag: Enabled: false @@ -62,7 +67,7 @@ RSpec/NestedGroups: RSpec/Capybara/FeatureMethods: Enabled: false -RSpec/Capybara/SpecificMatcher: +RSpec/Capybara: Enabled: false RSpec/MultipleMemoizedHelpers: @@ -71,6 +76,10 @@ RSpec/MultipleMemoizedHelpers: RSpec/AnyInstance: Exclude: - 'spec/features/google_preview_link_spec.rb' + - 'spec/components/browse/call_number_navigation_spec.rb' + - 'spec/components/browse/facet_navigation_spec.rb' + - 'spec/components/browse/page_size_selector_spec.rb' + - 'spec/components/browse/prefix_selector_spec.rb' RSpec/RepeatedExampleGroupBody: Exclude: diff --git a/.rubocop_todo.yml b/.rubocop_todo.yml index 0c5c0453..04d05aa2 100644 --- a/.rubocop_todo.yml +++ b/.rubocop_todo.yml @@ -36,7 +36,7 @@ Performance/CollectionLiteralInLoop: - 'config/environments/production.rb' # Offense count: 25 -RSpec/Capybara/SpecificMatcher: +RSpec/Capybara: Exclude: - 'spec/components/psul_constraint_layout_component_spec.rb' - 'spec/features/ask_a_librarian_spec.rb' diff --git a/Gemfile b/Gemfile index ea0f12bc..c2a019d8 100644 --- a/Gemfile +++ b/Gemfile @@ -22,19 +22,20 @@ gem 'net-imap', require: false gem 'net-pop', require: false gem 'net-smtp', require: false gem 'okcomputer', '~> 1.18' -gem 'puma', '~> 5.6' +gem 'puma', '~> 6' gem 'rack-mini-profiler' -gem 'rails', '~> 6.1.0' +gem 'rails', '~> 7.0' gem 'redis', '~> 5.0', '>= 5.0.6' gem 'rsolr', '>= 2.5' gem 'rubyzip' gem 'shakapacker', '= 7.1' gem 'shelvit' +gem 'sprockets-rails' gem 'stackprof' -gem 'blacklight', '~> 7.30' -gem 'blacklight_advanced_search', '~> 7.0' -gem 'blacklight-marc', '~> 7.0' +gem 'blacklight', '~> 8' +gem 'blacklight_advanced_search', '~> 8.0.0.alpha' +gem 'blacklight-marc', '~> 8.1' gem 'blacklight_range_limit' group :development do @@ -63,7 +64,7 @@ group :test do gem 'rspec-rails' gem 'selenium-webdriver' gem 'shoulda-matchers' - gem 'simplecov', '< 0.18', require: false # CodeClimate does not work with .18 or later + gem 'simplecov' gem 'vcr' gem 'webmock' end diff --git a/Gemfile.lock b/Gemfile.lock index 25dbfa28..213ac1b7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,73 +1,89 @@ GEM remote: https://rubygems.org/ specs: - actioncable (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) + actioncable (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) nio4r (~> 2.0) websocket-driver (>= 0.6.1) - actionmailbox (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + zeitwerk (~> 2.6) + actionmailbox (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (>= 2.7.1) - actionmailer (6.1.7.6) - actionpack (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activesupport (= 6.1.7.6) + net-imap + net-pop + net-smtp + actionmailer (7.1.3.2) + actionpack (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activesupport (= 7.1.3.2) mail (~> 2.5, >= 2.5.4) - rails-dom-testing (~> 2.0) - actionpack (6.1.7.6) - actionview (= 6.1.7.6) - activesupport (= 6.1.7.6) - rack (~> 2.0, >= 2.0.9) + net-imap + net-pop + net-smtp + rails-dom-testing (~> 2.2) + actionpack (7.1.3.2) + actionview (= 7.1.3.2) + activesupport (= 7.1.3.2) + nokogiri (>= 1.8.5) + racc + rack (>= 2.2.4) + rack-session (>= 1.0.1) rack-test (>= 0.6.3) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.0, >= 1.2.0) - actiontext (6.1.7.6) - actionpack (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + actiontext (7.1.3.2) + actionpack (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) + globalid (>= 0.6.0) nokogiri (>= 1.8.5) - actionview (6.1.7.6) - activesupport (= 6.1.7.6) + actionview (7.1.3.2) + activesupport (= 7.1.3.2) builder (~> 3.1) - erubi (~> 1.4) - rails-dom-testing (~> 2.0) - rails-html-sanitizer (~> 1.1, >= 1.2.0) - activejob (6.1.7.6) - activesupport (= 6.1.7.6) + erubi (~> 1.11) + rails-dom-testing (~> 2.2) + rails-html-sanitizer (~> 1.6) + activejob (7.1.3.2) + activesupport (= 7.1.3.2) globalid (>= 0.3.6) - activemodel (6.1.7.6) - activesupport (= 6.1.7.6) - activerecord (6.1.7.6) - activemodel (= 6.1.7.6) - activesupport (= 6.1.7.6) - activestorage (6.1.7.6) - actionpack (= 6.1.7.6) - activejob (= 6.1.7.6) - activerecord (= 6.1.7.6) - activesupport (= 6.1.7.6) + activemodel (7.1.3.2) + activesupport (= 7.1.3.2) + activerecord (7.1.3.2) + activemodel (= 7.1.3.2) + activesupport (= 7.1.3.2) + timeout (>= 0.4.0) + activestorage (7.1.3.2) + actionpack (= 7.1.3.2) + activejob (= 7.1.3.2) + activerecord (= 7.1.3.2) + activesupport (= 7.1.3.2) marcel (~> 1.0) - mini_mime (>= 1.1.0) - activesupport (6.1.7.6) + activesupport (7.1.3.2) + base64 + bigdecimal concurrent-ruby (~> 1.0, >= 1.0.2) + connection_pool (>= 2.2.5) + drb i18n (>= 1.6, < 2) minitest (>= 5.1) + mutex_m tzinfo (~> 2.0) - zeitwerk (~> 2.3) - addressable (2.8.5) + addressable (2.8.6) public_suffix (>= 2.0.2, < 6.0) ast (2.4.2) - bcrypt (3.1.18) - better_errors (2.9.1) - coderay (>= 1.0.0) + base64 (0.2.0) + bcrypt (3.1.20) + better_errors (2.10.1) erubi (>= 1.0.0) rack (>= 0.9.0) + rouge (>= 1.0.0) better_html (1.0.16) actionview (>= 4.0) activesupport (>= 4.0) @@ -76,109 +92,80 @@ GEM html_tokenizer (~> 0.0.6) parser (>= 2.4) smart_properties + bigdecimal (3.1.7) bindex (0.8.1) - binding_of_caller (1.0.0) - debug_inspector (>= 0.0.1) - blacklight (7.33.1) - deprecation + binding_of_caller (1.0.1) + debug_inspector (>= 1.2.0) + blacklight (8.1.0) globalid - hashdiff i18n (>= 1.7.0) jbuilder (~> 2.7) kaminari (>= 0.15) ostruct (>= 0.3.2) - rails (>= 5.1, < 7.1) - view_component (~> 2.66) - blacklight-marc (7.2.0) - blacklight (~> 7.0) + rails (>= 6.1, < 8) + view_component (>= 2.66, < 4) + blacklight-marc (8.1.3) + blacklight (>= 7.11, < 9) library_stdnums marc (>= 0.4.3, < 2.0) marc-fastxmlwriter rails traject (~> 3.0) - blacklight_advanced_search (7.0.0) - blacklight (~> 7.0) + blacklight_advanced_search (8.0.0.alpha2) + blacklight (>= 7.15, < 9) parslet - blacklight_range_limit (8.1.0) - blacklight (~> 7.0) - bootsnap (1.13.0) + blacklight_range_limit (8.5.0) + blacklight (>= 7.25.2, < 9) + deprecation + view_component (>= 2.54, < 4) + bootsnap (1.18.3) msgpack (~> 1.2) builder (3.2.4) byebug (11.1.3) - capybara (3.39.2) + capybara (3.40.0) addressable matrix mini_mime (>= 0.1.3) - nokogiri (~> 1.8) + nokogiri (~> 1.11) rack (>= 1.6.0) rack-test (>= 0.6.3) regexp_parser (>= 1.5, < 3.0) xpath (~> 3.2) + childprocess (5.0.0) coderay (1.1.3) colorize (0.8.1) - concurrent-ruby (1.2.2) - config (4.0.0) + concurrent-ruby (1.2.3) + config (5.4.0) deep_merge (~> 1.2, >= 1.2.1) - dry-validation (~> 1.0, >= 1.0.0) connection_pool (2.4.1) - crack (0.4.5) + crack (1.0.0) + bigdecimal rexml crass (1.0.6) - date (3.3.3) + date (3.3.4) ddtrace (1.11.1) debase-ruby_core_source (>= 0.10.16, <= 3.2.0) libdatadog (~> 2.0.0.1.0) libddwaf (~> 1.8.2.0.0) msgpack debase-ruby_core_source (3.2.0) - debug_inspector (1.1.0) + debug_inspector (1.2.0) deep_merge (1.2.2) deprecation (1.1.0) activesupport - devise (4.8.1) + devise (4.9.3) bcrypt (~> 3.0) orm_adapter (~> 0.1) railties (>= 4.1.0) responders warden (~> 1.2.3) - devise-guests (0.8.1) + devise-guests (0.8.2) devise - diff-lcs (1.5.0) + diff-lcs (1.5.1) docile (1.4.0) - domain_name (0.5.20190701) - unf (>= 0.0.5, < 1.0.0) + domain_name (0.6.20240107) dot-properties (0.1.3) - dry-configurable (0.15.0) - concurrent-ruby (~> 1.0) - dry-core (~> 0.6) - dry-container (0.10.1) - concurrent-ruby (~> 1.0) - dry-core (0.8.1) - concurrent-ruby (~> 1.0) - dry-inflector (0.3.0) - dry-initializer (3.1.1) - dry-logic (1.2.0) - concurrent-ruby (~> 1.0) - dry-core (~> 0.5, >= 0.5) - dry-schema (1.9.3) - concurrent-ruby (~> 1.0) - dry-configurable (~> 0.13, >= 0.13.0) - dry-core (~> 0.5, >= 0.5) - dry-initializer (~> 3.0) - dry-logic (~> 1.0) - dry-types (~> 1.5) - dry-types (1.5.1) - concurrent-ruby (~> 1.0) - dry-container (~> 0.3) - dry-core (~> 0.5, >= 0.5) - dry-inflector (~> 0.1, >= 0.1.2) - dry-logic (~> 1.0, >= 1.0.2) - dry-validation (1.8.1) - concurrent-ruby (~> 1.0) - dry-container (~> 0.7, >= 0.7.1) - dry-core (~> 0.5, >= 0.5) - dry-initializer (~> 3.0) - dry-schema (~> 1.8, >= 1.8.0) + drb (2.2.1) erb_lint (0.0.37) activesupport better_html (~> 1.0.7) @@ -188,7 +175,7 @@ GEM rubocop smart_properties erubi (1.12.0) - faraday (1.10.0) + faraday (1.10.3) faraday-em_http (~> 1.0) faraday-em_synchrony (~> 1.0) faraday-excon (~> 1.1) @@ -211,32 +198,37 @@ GEM faraday-patron (1.0.0) faraday-rack (1.0.0) faraday-retry (1.0.3) - ffi (1.15.5) - ffi-compiler (1.0.1) - ffi (>= 1.0.0) + ffi (1.16.3) + ffi-compiler (1.3.2) + ffi (>= 1.15.5) rake flamegraph (0.9.5) globalid (1.2.1) activesupport (>= 6.1) - hashdiff (1.0.1) + hashdiff (1.1.0) hashie (5.0.0) high_voltage (3.1.2) - html_tokenizer (0.0.7) - http (5.1.0) + html_tokenizer (0.0.8) + http (5.2.0) addressable (~> 2.8) + base64 (~> 0.1) http-cookie (~> 1.0) http-form_data (~> 2.2) - llhttp-ffi (~> 0.4.0) + llhttp-ffi (~> 0.5.0) http-cookie (1.0.5) domain_name (~> 0.5) http-form_data (2.3.0) httpclient (2.8.3) - i18n (1.14.1) + i18n (1.14.4) concurrent-ruby (~> 1.0) - jbuilder (2.11.5) + io-console (0.7.2) + irb (1.13.0) + rdoc (>= 4.0.0) + reline (>= 0.4.2) + jbuilder (2.12.0) actionview (>= 5.0.0) activesupport (>= 5.0.0) - json (2.6.2) + json (2.7.1) kaminari (1.2.2) activesupport (>= 4.1.0) kaminari-actionview (= 1.2.2) @@ -249,25 +241,26 @@ GEM activerecord kaminari-core (= 1.2.2) kaminari-core (1.2.2) - launchy (2.5.0) - addressable (~> 2.7) + launchy (3.0.0) + addressable (~> 2.8) + childprocess (~> 5.0) lcsort (0.9.1) libdatadog (2.0.0.1.0) libddwaf (1.8.2.0.0) ffi (~> 1.0) library_stdnums (1.6.0) - listen (3.7.1) + listen (3.9.0) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - llhttp-ffi (0.4.0) + llhttp-ffi (0.5.0) ffi-compiler (~> 1.0) rake (~> 13.0) - lograge (0.12.0) + lograge (0.14.0) actionpack (>= 4) activesupport (>= 4) railties (>= 4) request_store (~> 1.0) - loofah (2.21.4) + loofah (2.22.0) crass (~> 1.0.2) nokogiri (>= 1.12.0) mail (2.8.1) @@ -275,32 +268,33 @@ GEM net-imap net-pop net-smtp - marc (1.1.1) + marc (1.2.0) rexml scrub_rb (>= 1.0.1, < 2) unf marc-fastxmlwriter (1.1.0) marc (~> 1.0) - marcel (1.0.2) + marcel (1.0.4) matrix (0.4.2) - memory_profiler (1.0.0) - method_source (1.0.0) + memory_profiler (1.0.1) + method_source (1.1.0) mini_mime (1.1.5) - mini_portile2 (2.8.5) - minitest (5.20.0) - msgpack (1.5.4) - multipart-post (2.2.3) - mustermann (2.0.2) + mini_portile2 (2.8.6) + minitest (5.22.3) + msgpack (1.7.2) + multipart-post (2.4.0) + mustermann (3.0.0) ruby2_keywords (~> 0.0.1) - mysql2 (0.5.4) - net-imap (0.4.3) + mutex_m (0.2.0) + mysql2 (0.5.6) + net-imap (0.4.10) date net-protocol net-pop (0.1.2) net-protocol - net-protocol (0.2.1) + net-protocol (0.2.2) timeout - net-smtp (0.4.0) + net-smtp (0.5.0) net-protocol niftany (0.10.1) colorize (~> 0.8.1) @@ -310,51 +304,59 @@ GEM rubocop-rails (~> 2.3) rubocop-rspec (~> 2) scss_lint (~> 0.55) - nio4r (2.7.0) - nokogiri (1.15.4) + nio4r (2.7.1) + nokogiri (1.16.4) mini_portile2 (~> 2.8.2) racc (~> 1.4) - okcomputer (1.18.4) + okcomputer (1.18.5) orm_adapter (0.5.0) - ostruct (0.5.5) - parallel (1.22.1) - parser (3.1.2.0) + ostruct (0.6.0) + parallel (1.24.0) + parser (3.3.0.5) ast (~> 2.4.1) + racc parslet (2.0.0) - pry (0.13.1) + pry (0.14.2) coderay (~> 1.1) method_source (~> 1.0) - pry-byebug (3.9.0) + pry-byebug (3.10.1) byebug (~> 11.0) - pry (~> 0.13.0) - public_suffix (5.0.3) - puma (5.6.8) + pry (>= 0.13, < 0.15) + psych (5.1.2) + stringio + public_suffix (5.0.5) + puma (6.4.2) nio4r (~> 2.0) - racc (1.7.1) - rack (2.2.8) - rack-mini-profiler (3.0.0) + racc (1.7.3) + rack (3.0.10) + rack-mini-profiler (3.3.1) rack (>= 1.2.0) - rack-protection (2.2.3) - rack + rack-protection (4.0.0) + base64 (>= 0.1.0) + rack (>= 3.0.0, < 4) rack-proxy (0.7.7) rack + rack-session (2.0.0) + rack (>= 3.0.0) rack-test (2.1.0) rack (>= 1.3) - rails (6.1.7.6) - actioncable (= 6.1.7.6) - actionmailbox (= 6.1.7.6) - actionmailer (= 6.1.7.6) - actionpack (= 6.1.7.6) - actiontext (= 6.1.7.6) - actionview (= 6.1.7.6) - activejob (= 6.1.7.6) - activemodel (= 6.1.7.6) - activerecord (= 6.1.7.6) - activestorage (= 6.1.7.6) - activesupport (= 6.1.7.6) + rackup (2.1.0) + rack (>= 3) + webrick (~> 1.8) + rails (7.1.3.2) + actioncable (= 7.1.3.2) + actionmailbox (= 7.1.3.2) + actionmailer (= 7.1.3.2) + actionpack (= 7.1.3.2) + actiontext (= 7.1.3.2) + actionview (= 7.1.3.2) + activejob (= 7.1.3.2) + activemodel (= 7.1.3.2) + activerecord (= 7.1.3.2) + activestorage (= 7.1.3.2) + activesupport (= 7.1.3.2) bundler (>= 1.15.0) - railties (= 6.1.7.6) - sprockets-rails (>= 2.0.0) + railties (= 7.1.3.2) rails-controller-testing (1.0.5) actionpack (>= 5.0.1.rc1) actionview (>= 5.0.1.rc1) @@ -366,52 +368,59 @@ GEM rails-html-sanitizer (1.6.0) loofah (~> 2.21) nokogiri (~> 1.14) - railties (6.1.7.6) - actionpack (= 6.1.7.6) - activesupport (= 6.1.7.6) - method_source + railties (7.1.3.2) + actionpack (= 7.1.3.2) + activesupport (= 7.1.3.2) + irb + rackup (>= 1.0.0) rake (>= 12.2) - thor (~> 1.0) + thor (~> 1.0, >= 1.2.2) + zeitwerk (~> 2.6) rainbow (3.1.1) - rake (13.1.0) - rb-fsevent (0.11.1) + rake (13.2.1) + rb-fsevent (0.11.2) rb-inotify (0.10.1) ffi (~> 1.0) - redis (5.0.6) - redis-client (>= 0.9.0) - redis-client (0.14.1) + rdoc (6.6.3.1) + psych (>= 4.0.0) + redis (5.1.0) + redis-client (>= 0.17.0) + redis-client (0.21.1) connection_pool - regexp_parser (2.8.1) - request_store (1.5.1) + regexp_parser (2.9.0) + reline (0.5.5) + io-console (~> 0.5) + request_store (1.6.0) rack (>= 1.4) - responders (3.0.1) - actionpack (>= 5.0) - railties (>= 5.0) + responders (3.1.1) + actionpack (>= 5.2) + railties (>= 5.2) rexml (3.2.6) - rsolr (2.5.0) + rouge (4.2.1) + rsolr (2.6.0) builder (>= 2.1.2) faraday (>= 0.9, < 3, != 2.0.0) - rspec-core (3.11.0) - rspec-support (~> 3.11.0) - rspec-expectations (3.11.0) + rspec-core (3.13.0) + rspec-support (~> 3.13.0) + rspec-expectations (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) + rspec-support (~> 3.13.0) rspec-its (1.3.0) rspec-core (>= 3.0.0) rspec-expectations (>= 3.0.0) - rspec-mocks (3.11.1) + rspec-mocks (3.13.0) diff-lcs (>= 1.2.0, < 2.0) - rspec-support (~> 3.11.0) - rspec-rails (5.1.2) - actionpack (>= 5.2) - activesupport (>= 5.2) - railties (>= 5.2) - rspec-core (~> 3.10) - rspec-expectations (~> 3.10) - rspec-mocks (~> 3.10) - rspec-support (~> 3.10) - rspec-support (3.11.0) - rubocop (1.32.0) + rspec-support (~> 3.13.0) + rspec-rails (6.1.2) + actionpack (>= 6.1) + activesupport (>= 6.1) + railties (>= 6.1) + rspec-core (~> 3.13) + rspec-expectations (~> 3.13) + rspec-mocks (~> 3.13) + rspec-support (~> 3.13) + rspec-support (3.13.1) + rubocop (1.33.0) json (~> 2.3) parallel (~> 1.10) parser (>= 3.1.0.0) @@ -441,9 +450,10 @@ GEM rb-fsevent (~> 0.9, >= 0.9.4) rb-inotify (~> 0.9, >= 0.9.7) scrub_rb (1.0.1) - scss_lint (0.59.0) + scss_lint (0.60.0) sass (~> 3.5, >= 3.5.5) - selenium-webdriver (4.12.0) + selenium-webdriver (4.19.0) + base64 (~> 0.2) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) @@ -455,26 +465,28 @@ GEM semantic_range (>= 2.3.0) shelvit (0.1.2) lcsort (~> 0.9) - shoulda-matchers (5.1.0) + shoulda-matchers (6.2.0) activesupport (>= 5.2.0) - simplecov (0.17.1) + simplecov (0.22.0) docile (~> 1.1) - json (>= 1.8, < 3) - simplecov-html (~> 0.10.0) - simplecov-html (0.10.2) - sinatra (2.2.3) - mustermann (~> 2.0) - rack (~> 2.2) - rack-protection (= 2.2.3) + simplecov-html (~> 0.11) + simplecov_json_formatter (~> 0.1) + simplecov-html (0.12.3) + simplecov_json_formatter (0.1.4) + sinatra (4.0.0) + mustermann (~> 3.0) + rack (>= 3.0.0, < 4) + rack-protection (= 4.0.0) + rack-session (>= 2.0.0, < 3) tilt (~> 2.0) - slop (4.9.2) + slop (4.10.1) smart_properties (1.17.0) - spring (2.1.1) + spring (4.1.3) spring-commands-rspec (1.0.4) spring (>= 0.9.1) - spring-watcher-listen (2.0.1) + spring-watcher-listen (2.1.0) listen (>= 2.7, < 4.0) - spring (>= 1.2, < 3.0) + spring (>= 4) sprockets (4.2.1) concurrent-ruby (~> 1.0) rack (>= 2.2.4, < 4) @@ -482,12 +494,14 @@ GEM actionpack (>= 5.2) activesupport (>= 5.2) sprockets (>= 3.0.0) - sqlite3 (1.4.4) - stackprof (0.2.20) - thor (1.3.0) - tilt (2.0.11) - timeout (0.4.0) - traject (3.7.0) + sqlite3 (1.7.3) + mini_portile2 (~> 2.8.0) + stackprof (0.2.26) + stringio (3.1.0) + thor (1.3.1) + tilt (2.3.0) + timeout (0.4.1) + traject (3.8.2) concurrent-ruby (>= 0.8.0) dot-properties (>= 0.1.1) hashie (>= 3.1, < 6) @@ -502,32 +516,33 @@ GEM concurrent-ruby (~> 1.0) unf (0.1.4) unf_ext - unf_ext (0.0.8.2) - unicode-display_width (2.2.0) - vcr (6.1.0) - view_component (2.83.0) + unf_ext (0.0.9.1) + unicode-display_width (2.5.0) + vcr (6.2.0) + view_component (3.12.1) activesupport (>= 5.2.0, < 8.0) concurrent-ruby (~> 1.0) method_source (~> 1.0) warden (1.2.9) rack (>= 2.0.9) - web-console (4.2.0) + web-console (4.2.1) actionview (>= 6.0.0) activemodel (>= 6.0.0) bindex (>= 0.4.0) railties (>= 6.0.0) - webmock (3.17.1) + webmock (3.23.0) addressable (>= 2.8.0) crack (>= 0.3.2) hashdiff (>= 0.4.0, < 2.0.0) - websocket (1.2.9) + webrick (1.8.1) + websocket (1.2.10) websocket-driver (0.7.6) websocket-extensions (>= 0.1.0) websocket-extensions (0.1.5) xpath (3.2.0) nokogiri (~> 1.8) yell (2.2.2) - zeitwerk (2.6.12) + zeitwerk (2.6.13) PLATFORMS ruby @@ -535,9 +550,9 @@ PLATFORMS DEPENDENCIES better_errors binding_of_caller - blacklight (~> 7.30) - blacklight-marc (~> 7.0) - blacklight_advanced_search (~> 7.0) + blacklight (~> 8) + blacklight-marc (~> 8.1) + blacklight_advanced_search (~> 8.0.0.alpha) blacklight_range_limit bootsnap byebug @@ -561,9 +576,9 @@ DEPENDENCIES niftany (~> 0.10) okcomputer (~> 1.18) pry-byebug - puma (~> 5.6) + puma (~> 6) rack-mini-profiler - rails (~> 6.1.0) + rails (~> 7.0) rails-controller-testing redis (~> 5.0, >= 5.0.6) rsolr (>= 2.5) @@ -574,11 +589,12 @@ DEPENDENCIES shakapacker (= 7.1) shelvit shoulda-matchers - simplecov (< 0.18) + simplecov sinatra spring spring-commands-rspec spring-watcher-listen + sprockets-rails sqlite3 stackprof vcr diff --git a/app/assets/config/manifest.js b/app/assets/config/manifest.js new file mode 100644 index 00000000..329a27d9 --- /dev/null +++ b/app/assets/config/manifest.js @@ -0,0 +1 @@ +// .keep \ No newline at end of file diff --git a/app/components/blacklight/advanced_search_form_component.html.erb b/app/components/blacklight/advanced_search_form_component.html.erb new file mode 100644 index 00000000..a2f5d38d --- /dev/null +++ b/app/components/blacklight/advanced_search_form_component.html.erb @@ -0,0 +1,58 @@ +<%= form_tag @url, method: @method, class: @classes.join(' '), role: 'search', 'aria-label' => t('blacklight.search.form.submit') do %> + +

+ <%= t('blacklight_advanced_search.form.title') %> + + + <%= button_tag t('blacklight_advanced_search.form.start_over'), type: 'reset', class: 'btn btn-secondary pull-right advanced-search-start-over' %> + <%= submit_tag t('blacklight_advanced_search.form.search_btn'), class: 'btn btn-primary advanced-search-submit', id: 'advanced-search-submit-top' %> + +

+ +
+
+

+ <%= t('blacklight_advanced_search.form.query_criteria_heading_html', select_menu: default_operator_menu) %> +

+ + +
+ + <% if search_filter_controls? %> +
+

<%= t('blacklight.advanced_search.form.limit_criteria_heading_html') %>

+ +
+
+ <% search_filter_controls.each do |control| %> + <%= control %> + <% end %> +
+
+
+ <% end %> +
+ + <%# Publication Date is a range input %> +<% pub_date = helpers.facet_configuration_for_field('pub_date_itsi') %> +
+ <%= label_tag pub_date.field.parameterize, class: 'col-sm-4 control-label' do %> + <%= pub_date.label %> + <% end %> +
+ + <%= number_field_tag('range[pub_date_itsi][begin]', nil, maxlength: 6, class: 'form-control text-center range_begin') %> – + + <%= number_field_tag('range[pub_date_itsi][end]', nil, maxlength: 6, class: 'form-control text-center range_end') %> +
+
+ +
+ <%= render 'advanced_search_submit_btns' %> +
+ +<% end %> diff --git a/app/components/blacklight/document/action_component.html.erb b/app/components/blacklight/document/action_component.html.erb new file mode 100644 index 00000000..cfedb494 --- /dev/null +++ b/app/components/blacklight/document/action_component.html.erb @@ -0,0 +1 @@ +<%= render_control %> diff --git a/app/components/blacklight/document/action_component.rb b/app/components/blacklight/document/action_component.rb new file mode 100644 index 00000000..8f864806 --- /dev/null +++ b/app/components/blacklight/document/action_component.rb @@ -0,0 +1,75 @@ +# frozen_string_literal: true + +module Blacklight + module Document + # Render a bookmark widget to bookmark / unbookmark a document + class ActionComponent < Blacklight::Component + with_collection_parameter :action + + # @param [Blacklight::Document] document + def initialize(document:, action:, options: {}, url_opts: {}, id: nil, link_classes: 'nav-link') + @document = document + @action = action + @options = options + @url_opts = url_opts + @id = id || @action.fetch(:id, "#{@action.name}Link") + @link_classes = link_classes + end + + def render_control + return link_to_modal_control if using_default_document_action? && url + + render_partial + end + + def using_default_document_action? + @action.component || @action.partial == 'document_action' + end + + def link_to_modal_control + link_to label, + url, + id: @id, + class: @link_classes, + data: {}.merge(({ blacklight_modal: 'trigger', turbo: false } if @action.modal != false) || {}) + end + + def render_partial + helpers.render(partial: @action.partial || @action.name.to_s, + locals: { document: @document, + document_action_config: @action }.merge(@options)) + end + + def label + t("blacklight.tools.#{@action.name}", default: @action.label || @action.name.to_s.humanize) + end + + # Action buttons get their URLs in one of three ways: + # - the action configuration explicitly specifies a helper method to call + # - a url route is inferred for ActiveModel-compliant objects (the default; + # note that, although Rails routing is available here, we still call out to + # helpers regardless, because that's where applications might have overridden the + # default Rails routing behavior) + # - calling out to an implicit helper method with a conventional name (unlikely) + def url + url_opts = @url_opts.merge(({ id: @document } if @document) || {}) + if @action.path + helpers.public_send(@action.path, url_opts) + elsif url_opts[:id].class.respond_to?(:model_name) + helpers.url_for([@action.key.to_sym, url_opts[:id]]) + elsif @action.key == :bulk_ris && helpers.controller_name == 'bookmarks' + bookmark_ids = helpers.current_user.bookmarks.map { |b| b.document_id.to_s }.join(',') + helpers.public_send("#{@action.key}_#{helpers.controller_name}_path", bookmark_ids) + elsif !(@action.key == :ris && helpers.controller_name == 'bookmarks') + helpers.public_send("#{@action.key}_#{helpers.controller_name}_path", url_opts) + else + '' + end + end + + def key + @action.key + end + end + end +end diff --git a/app/components/blacklight/facet_field_checkboxes_component.html.erb b/app/components/blacklight/facet_field_checkboxes_component.html.erb new file mode 100644 index 00000000..c8512b3c --- /dev/null +++ b/app/components/blacklight/facet_field_checkboxes_component.html.erb @@ -0,0 +1,18 @@ +
+

<%= @facet_field.label %> + + <%= content_tag(:select, + multiple: true, + name: "f_inclusive[#{@facet_field.key}][]", + id: @facet_field.key, + class: 'form-control selectpicker', + data: { 'live-search': 'true', placeholder: "Type or select #{@facet_field.key.downcase.pluralize}" }) do %> + <% presenters.each_with_index do |presenter, idx| -%> + <%= content_tag :option, value: presenter.value do %> + <%= presenter.label %> + <% end %> + <% end %> + <% end %> + +

+
diff --git a/app/components/browse/paths.rb b/app/components/browse/paths.rb index 1f59f8af..58ac83e7 100644 --- a/app/components/browse/paths.rb +++ b/app/components/browse/paths.rb @@ -2,11 +2,11 @@ module Browse::Paths def browse_path(args) - send("#{action.singularize}_browse_path", args) + send(:"#{action.singularize}_browse_path", args) end def browse_url - send("#{action.singularize}_browse_url") + send(:"#{action.singularize}_browse_url") end private diff --git a/app/components/external_links/google_preview_link_component.rb b/app/components/external_links/google_preview_link_component.rb index c85eb35d..9059374f 100644 --- a/app/components/external_links/google_preview_link_component.rb +++ b/app/components/external_links/google_preview_link_component.rb @@ -41,7 +41,7 @@ def free_to_read? def hathi_link? document[:document]['ht_access_ss'] == 'allow' || - (document[:document]['ht_access_ss'] == 'deny' && Settings&.hathi_etas) + (document[:document]['ht_access_ss'] == 'deny' && Settings.hathi_etas) end attr_reader :document diff --git a/app/components/psul_search_bar_component.rb b/app/components/psul_search_bar_component.rb new file mode 100644 index 00000000..4b8a5668 --- /dev/null +++ b/app/components/psul_search_bar_component.rb @@ -0,0 +1,36 @@ +# frozen_string_literal: true + +class PsulSearchBarComponent < Blacklight::SearchBarComponent + def search_fields + @search_fields ||= blacklight_config.search_fields.values + .reject { |field_def| field_def&.include_in_simple_select == false } + .map do |field_def| + [field_def.dropdown_label || field_def.label, + field_def.key, + { 'data-placeholder' => (field_def.placeholder_text || t('blacklight.search.form.search.placeholder')) }] + end + end + + def before_render + super + return if @search_field + + @search_field = case params[:action] + when 'call_numbers' + case params[:classification] + when 'lc' + 'browse_lc' + when 'dewey' + 'browse_dewey' + end + when 'authors' + 'browse_authors' + when 'subjects' + 'browse_subjects' + when 'titles' + 'browse_titles' + else + params[:search_field] + end + end +end diff --git a/app/controllers/catalog_controller.rb b/app/controllers/catalog_controller.rb index a5d05596..23b2fcfe 100644 --- a/app/controllers/catalog_controller.rb +++ b/app/controllers/catalog_controller.rb @@ -4,6 +4,8 @@ class CatalogController < ApplicationController include BlacklightAdvancedSearch::Controller include BlacklightRangeLimit::ControllerOverride include Blacklight::Catalog + include Blacklight::Configurable + include Blacklight::SearchContext include Blacklight::Marc::Catalog include Blacklight::Searchable include Browse @@ -20,7 +22,7 @@ def index if cache_key @response = Rails.cache.fetch(cache_key, expires_in: 12.hours) do - response = search_service.search_results.first + response = search_service.search_results # Nilling out below is necessary in order to avoid a Marshal.dump error of "can't dump an anonymous class" when # attempting to cache the Solr response object. response.blacklight_config = nil @@ -34,7 +36,7 @@ def index blacklight_config: blacklight_config } else - @response = search_service.search_results.first + @response = search_service.search_results end respond_to do |format| @@ -208,46 +210,6 @@ def ris config.add_facet_field 'title_sort', label: 'Title', show: false config.add_facet_field 'thesis_dept_facet', label: 'Graduate Program', show: false - # - # Facets that only appear on the home page - # - config.add_home_facet_field 'access_facet', - label: 'Access', - collapse: false, - presenter: Blacklight::FacetFieldPresenter - - config.add_home_facet_field 'format', - label: 'Format', - limit: true, - collapse: false, - presenter: Blacklight::FacetFieldPresenter - - config.add_home_facet_field 'campus_facet', - label: 'Campus', - sort: 'index', - limit: -1, - single: true, - collapse: true, - presenter: Blacklight::FacetFieldPresenter - - config.add_home_facet_field 'media_type_facet', - label: 'Media Type', - limit: 20, - index_range: 'A'..'Z', - collapse: true, - presenter: Blacklight::FacetFieldPresenter - - config.add_home_facet_field 'classification_pivot_field', - label: 'Call Number', - pivot: %w[lc_1letter_facet lc_rest_facet], - collapse: true, - collapsing: true, - presenter: Blacklight::FacetFieldPresenter, - icons: { - show: "\uf0fe", # same as '', - hide: "\uf146" - } - # Have BL send all facet field names to Solr, which has been the default # previously. Simply remove these lines if you'd rather use Solr request # handler defaults, or have no facets. diff --git a/app/controllers/search_history_controller.rb b/app/controllers/search_history_controller.rb index 6e0f48f3..9ee946ce 100644 --- a/app/controllers/search_history_controller.rb +++ b/app/controllers/search_history_controller.rb @@ -3,9 +3,8 @@ class SearchHistoryController < ApplicationController include Blacklight::SearchHistory - # TODO: Consider deleting the following three lines altogether. The following lines were generated during an install. + # TODO: Consider deleting the following two lines altogether. The following lines were generated during an install. # Removing these lines has zero effect on the display of constraints. helper BlacklightAdvancedSearch::RenderConstraintsOverride - helper BlacklightRangeLimit::ViewHelperOverride helper RangeLimitHelper end diff --git a/app/helpers/catalog_helper.rb b/app/helpers/catalog_helper.rb index 56abe54a..6429847e 100644 --- a/app/helpers/catalog_helper.rb +++ b/app/helpers/catalog_helper.rb @@ -87,20 +87,6 @@ def get_first_only(options = {}) options[:value].first end - # Returns suitable argument to options_for_select method, to create - # an html select based on #search_field_list with labels for search - # bar only. Skips search_fields marked :include_in_simple_select => false - def search_bar_select - blacklight_config.search_fields.map do |_key, field_def| - if should_render_field?(field_def) - [ - field_def.dropdown_label || - field_def.label, field_def.key, { 'data-placeholder' => placeholder_text(field_def) } - ] - end - end.compact - end - def placeholder_text(field_def) if field_def.respond_to?(:placeholder_text) field_def.placeholder_text @@ -108,24 +94,4 @@ def placeholder_text(field_def) t('blacklight.search.form.search.placeholder') end end - - def search_bar_field - case params[:action] - when 'call_numbers' - case params[:classification] - when 'lc' - 'browse_lc' - when 'dewey' - 'browse_dewey' - end - when 'authors' - 'browse_authors' - when 'subjects' - 'browse_subjects' - when 'titles' - 'browse_titles' - else - params[:search_field] - end - end end diff --git a/app/helpers/url_helper.rb b/app/helpers/url_helper.rb index fddfce4a..758996ba 100644 --- a/app/helpers/url_helper.rb +++ b/app/helpers/url_helper.rb @@ -9,17 +9,17 @@ module UrlHelper # @example # session_tracking_params(SolrDocument.new(id: 123), 7) # => { data: { :'context-href' => '/catalog/123/track?counter=7&search_id=999' } } - def session_tracking_params(document, counter) - path = session_tracking_path(document, - per_page: params.fetch(:per_page, search_session['per_page']), - counter: counter, - search_id: current_search_session.try(:id), - document_id: document&.id) - if path.nil? - return {} + def session_tracking_params document, counter, per_page: search_session['per_page'], search_id: current_search_session&.id + path_params = { per_page: params.fetch(:per_page, per_page), counter: counter, search_id: search_id } + if blacklight_config.track_search_session.storage == 'server' + path_params[:document_id] = document&.id + path_params[:search_id] = search_id end + path = session_tracking_path(document, path_params) + return {} if path.nil? - { data: { 'context-href': path } } + context_method = blacklight_config.track_search_session.storage == 'client' ? 'get' : 'post' + { data: { context_href: path, context_method: context_method, turbo_prefetch: false } } end end diff --git a/app/models/concerns/blacklight/document/email.rb b/app/models/concerns/blacklight/document/email.rb index 3dee79e3..6f28ef7f 100644 --- a/app/models/concerns/blacklight/document/email.rb +++ b/app/models/concerns/blacklight/document/email.rb @@ -18,6 +18,6 @@ def to_email_text label = 'blacklight.email.text.holdings' body << I18n.t(label, value: availability) unless availability.nil? - return body.join("\n") unless body.empty? + body.join("\n") unless body.empty? end end diff --git a/app/models/concerns/blacklight/document/sms.rb b/app/models/concerns/blacklight/document/sms.rb index 781788f1..fceae10b 100644 --- a/app/models/concerns/blacklight/document/sms.rb +++ b/app/models/concerns/blacklight/document/sms.rb @@ -14,6 +14,6 @@ def to_sms_text body << I18n.t(label, value: value.join('; ')) end end - return body.join("\n") unless body.empty? + body.join("\n") unless body.empty? end end diff --git a/app/models/hathi_links.rb b/app/models/hathi_links.rb index ddc07073..cc9568b6 100644 --- a/app/models/hathi_links.rb +++ b/app/models/hathi_links.rb @@ -39,7 +39,7 @@ def ht_additional_text end def etas_item? - ht_access == 'deny' && Settings&.hathi_etas + ht_access == 'deny' && Settings.hathi_etas end def open_ht_access? diff --git a/app/models/shelf_item.rb b/app/models/shelf_item.rb index 867fbd02..fef8828a 100644 --- a/app/models/shelf_item.rb +++ b/app/models/shelf_item.rb @@ -38,7 +38,7 @@ def more_call_numbers keymap .select { |cn| all_shelfkeys.include?(cn['key']) } - .map { |cn| cn['call_number'] } + .pluck('call_number') end def add(document) diff --git a/app/presenters/shelf_list_presenter.rb b/app/presenters/shelf_list_presenter.rb index 20fa478b..34ebe9dd 100644 --- a/app/presenters/shelf_list_presenter.rb +++ b/app/presenters/shelf_list_presenter.rb @@ -23,13 +23,7 @@ def initialize(params = {}) end def length - if @length > MAX - MAX - elsif @length < MIN - MIN - else - @length - end + @length.clamp(MIN, MAX) end def list diff --git a/app/services/browse_list.rb b/app/services/browse_list.rb index 96ece8c9..353f8e11 100644 --- a/app/services/browse_list.rb +++ b/app/services/browse_list.rb @@ -61,7 +61,7 @@ def normalize_prefix(prefix) normalized_prefix = prefix.dup - normalized_prefix.gsub!(/--/, '—') # replace 2 normal dashes with em dash + normalized_prefix.gsub!('--', '—') # replace 2 normal dashes with em dash normalized_prefix.chomp('*') # remove trailing * (wildcard chars) end end diff --git a/app/services/document_ris.rb b/app/services/document_ris.rb index 5c5d1198..4a07e231 100644 --- a/app/services/document_ris.rb +++ b/app/services/document_ris.rb @@ -29,8 +29,7 @@ class DocumentRis }.freeze def initialize(document) - @document = document - @docs = @document.first['response']['docs'].first + @docs = document end def ris_to_string diff --git a/app/services/holdings_request_service.rb b/app/services/holdings_request_service.rb index fbdab864..7732aae0 100644 --- a/app/services/holdings_request_service.rb +++ b/app/services/holdings_request_service.rb @@ -98,6 +98,6 @@ def availability_to_string(availability) end def libraries_data - @libraries_data ||= JSON.parse(File.read(Rails.root.join('app/javascript/availability/libraries_locations.json'))) + @libraries_data ||= JSON.parse(Rails.root.join('app/javascript/availability/libraries_locations.json').read) end end diff --git a/app/views/advanced/_advanced_search_facets_as_select.html.erb b/app/views/advanced/_advanced_search_facets_as_select.html.erb deleted file mode 100644 index 1620be74..00000000 --- a/app/views/advanced/_advanced_search_facets_as_select.html.erb +++ /dev/null @@ -1,38 +0,0 @@ -<% facets_from_request(facet_field_names).each do |display_facet| %> - <% if display_facet.items.present? %> -
- <%= label_tag display_facet.name.parameterize, class: 'col-sm-3 control-label' do %> - <%= facet_field_label(display_facet.name) %> - <% end %> - -
- <%= content_tag(:select, - multiple: true, - name: "f_inclusive[#{display_facet.name}][]", - id: display_facet.name.parameterize, - class: 'form-control selectpicker', - data: { 'live-search': 'true', placeholder: "Type or select #{facet_field_label(display_facet.name).downcase.pluralize}" }) do %> - <% display_facet.items.each do |facet_item| %> - <%= content_tag :option, value: facet_item.value, selected: facet_value_checked?(display_facet.name, facet_item.value) do %> - <%= facet_display_value(display_facet.name, facet_item.label) %> - <% end %> - <% end %> - <% end %> -
-
- <% end %> -<% end %> - -<%# Publication Date is a range input %> -<% pub_date = facet_configuration_for_field('pub_date_itsi') %> -
- <%= label_tag pub_date.field.parameterize, class: 'col-sm-4 control-label' do %> - <%= pub_date.label %> - <% end %> -
- - <%= render_range_input(pub_date.field, :begin) %> – - - <%= render_range_input(pub_date.field, :end) %> -
-
diff --git a/app/views/advanced/_advanced_search_form.html.erb b/app/views/advanced/_advanced_search_form.html.erb deleted file mode 100644 index d020374f..00000000 --- a/app/views/advanced/_advanced_search_form.html.erb +++ /dev/null @@ -1,50 +0,0 @@ -<%= form_tag search_catalog_path, class: 'advanced form-horizontal', method: :get do %> -

- <%= t('blacklight_advanced_search.form.title') %> - - - <%= link_to t('blacklight_advanced_search.form.start_over'), blacklight_advanced_search_engine.advanced_search_path, class: 'btn btn-secondary pull-right advanced-search-start-over' %> - <%= submit_tag t('blacklight_advanced_search.form.search_btn'), class: 'btn btn-primary advanced-search-submit', id: 'advanced-search-submit-top' %> - -

- - <% unless (search_context_str = render_search_to_s( advanced_search_context)).blank? %> -
-

<%= t 'blacklight_advanced_search.form.search_context' %>

- <%= search_context_str %> -
- <% end %> - - <%= render_hash_as_hidden_fields(advanced_search_context) %> - -
-
-

- <%= t('blacklight_advanced_search.form.query_criteria_heading_html', select_menu: select_menu_for_field_operator) %> -

- - -
- -
-

<%= t('blacklight_advanced_search.form.limit_criteria_heading_html') %>

- -
- <% if blacklight_config.try(:advanced_search).try {|h| h[:form_facet_partial] } %> - <%= render blacklight_config.advanced_search[:form_facet_partial] %> - <% else %> - <%= render 'advanced_search_facets' %> - <% end %> -
-
-
- -
- -
- <%= render 'advanced_search_submit_btns' %> -
- -<% end %> diff --git a/app/views/blacklight_range_limit/_range_limit_panel.html.erb b/app/views/blacklight_range_limit/_range_limit_panel.html.erb index c55e5864..4adee352 100644 --- a/app/views/blacklight_range_limit/_range_limit_panel.html.erb +++ b/app/views/blacklight_range_limit/_range_limit_panel.html.erb @@ -25,7 +25,7 @@ <% unless selected_missing_for_range_limit?(field_name) %> <%= form_tag search_action_path, method: :get, class: [BlacklightRangeLimit.classes[:form], "range_#{field_name}"].join(' ') do %> - <%= render_hash_as_hidden_fields(search_state.params_for_search.except(:page)) %> + <%= render Blacklight::HiddenSearchStateComponent(params: search_state.params_for_search.except(:page)) %> - + <% end %> diff --git a/app/views/catalog/_show_top_fields.html.erb b/app/views/catalog/_show_top_fields.html.erb index a6ccf701..aeac281d 100644 --- a/app/views/catalog/_show_top_fields.html.erb +++ b/app/views/catalog/_show_top_fields.html.erb @@ -6,7 +6,7 @@
- <%= render_document_show_field_label document, field: field_name %> + <%= field.label %>
<%= doc_presenter.field_value field %>
<% end %> diff --git a/app/views/advanced/index.html.erb b/app/views/catalog/advanced_search.html.erb similarity index 78% rename from app/views/advanced/index.html.erb rename to app/views/catalog/advanced_search.html.erb index feb974db..7fd65f3d 100644 --- a/app/views/advanced/index.html.erb +++ b/app/views/catalog/advanced_search.html.erb @@ -1,5 +1,3 @@ -<% @page_title = "More Search Options - #{application_name}" %> -
diff --git a/app/views/catalog/index.html.erb b/app/views/catalog/index.html.erb index c0af2dbe..80ae136c 100644 --- a/app/views/catalog/index.html.erb +++ b/app/views/catalog/index.html.erb @@ -1,5 +1,9 @@ <% content_for(:sidebar) do %> - <%= render 'search_sidebar' %> + <% conf = blacklight_config.view_config(document_index_view_type) %> + + <%= render conf.sidebar_component.new(blacklight_config: blacklight_config, + response: @response, + view_config: conf) %> <% end %> <% unless has_search_parameters? %> diff --git a/app/views/catalog/show.html.erb b/app/views/catalog/show.html.erb index f2b541e5..814b4a58 100644 --- a/app/views/catalog/show.html.erb +++ b/app/views/catalog/show.html.erb @@ -1 +1 @@ -<%= render_document_main_content_partial %> +<%= render 'show_main_content' %> diff --git a/app/views/layouts/blacklight/base.html.erb b/app/views/layouts/blacklight/base.html.erb index 33efaa74..5b3a6b94 100644 --- a/app/views/layouts/blacklight/base.html.erb +++ b/app/views/layouts/blacklight/base.html.erb @@ -38,7 +38,7 @@ -<%= render partial: 'shared/announcement' unless Settings&.hide_announcement %> +<%= render partial: 'shared/announcement' unless Settings.hide_announcement %> <%= render partial: 'shared/header_navbar' %>
@@ -54,8 +54,8 @@ <%= link_back_to_catalog label: t('blacklight.back_to_search.html'), class: 'btn btn-outline-secondary btn-sm' %>
<% end %> + <%= render(Blacklight::SearchContext::ServerItemPaginationComponent.new(search_context: @search_context, search_session: search_session, current_document: @document)) if search_session['document_id'] == @document.id %> - <%= render 'previous_next_doc' if search_session['document_id'] == @document.id %> <% end %> <% if @document %> <%= render 'record_toolbar' %> diff --git a/app/views/shared/_announcement.html.erb b/app/views/shared/_announcement.html.erb index 5a1f70c5..77b208ef 100644 --- a/app/views/shared/_announcement.html.erb +++ b/app/views/shared/_announcement.html.erb @@ -1,7 +1,7 @@ -
+
-

<%= sanitize Settings&.announcement&.message || t('blacklight.announcement.message.html') %>

+

<%= sanitize Settings.announcement&.message || t('blacklight.announcement.message.html') %>

diff --git a/app/views/shared/_header_navbar.html.erb b/app/views/shared/_header_navbar.html.erb index 29e89ea1..7cf7fc81 100644 --- a/app/views/shared/_header_navbar.html.erb +++ b/app/views/shared/_header_navbar.html.erb @@ -8,10 +8,19 @@
-<% unless @search_fields_for_advanced_search %> +<% unless params['action'] == 'advanced_search' %> <% end %> diff --git a/config/application.rb b/config/application.rb index 5cce7c94..fb7775d7 100644 --- a/config/application.rb +++ b/config/application.rb @@ -14,7 +14,7 @@ require 'action_mailer/railtie' require 'action_view/railtie' # require "action_cable/engine" -# require "sprockets/railtie" +require 'sprockets/railtie' # require "rails/test_unit/railtie" # Require the gems listed in Gemfile, including any gems diff --git a/config/environments/development.rb b/config/environments/development.rb index feb81512..db5281db 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -11,7 +11,7 @@ # In the development environment your application's code is reloaded any time # it changes. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. - config.cache_classes = false + config.enable_reloading = true # Do not eager load code on boot. config.eager_load = false @@ -64,6 +64,9 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true + # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker diff --git a/config/environments/production.rb b/config/environments/production.rb index 49d71dea..38a015ee 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -6,7 +6,7 @@ # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. - config.cache_classes = true + config.enable_reloading = false # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers @@ -18,12 +18,11 @@ config.consider_all_requests_local = false config.action_controller.perform_caching = true - # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"] - # or in config/master.key. This key is used to decrypt credentials (and other encrypted files). + # Ensures that a master key has been made available in ENV["RAILS_MASTER_KEY"], config/master.key, or an environment + # key such as config/credentials/production.key. This key is used to decrypt credentials (and other encrypted files). # config.require_master_key = true - # Disable serving static files from the `/public` folder by default since - # Apache or NGINX already handles this. + # Disable serving static files from `public/`, relying on NGINX/Apache to do so instead. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Enable serving of images, stylesheets, and JavaScripts from an asset server. @@ -36,6 +35,10 @@ # Store uploaded files on the local file system (see config/storage.yml for options). config.active_storage.service = :local + # Assume all access to the app is happening through a SSL-terminating reverse proxy. + # Can be used together with config.force_ssl for Strict-Transport-Security and secure cookies. + # config.assume_ssl = true + # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true @@ -83,7 +86,7 @@ config.active_support.disallowed_deprecation_warnings = [] # Use default logging formatter so that PID and timestamp are not suppressed. - config.log_formatter = ::Logger::Formatter.new + config.log_formatter = Logger::Formatter.new # Use a different logger for distributed setups. # require "syslog/logger" diff --git a/config/environments/test.rb b/config/environments/test.rb index 74b1be28..8ae1da16 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -59,4 +59,7 @@ # Annotate rendered view with file names. # config.action_view.annotate_rendered_view_with_filenames = true + + # Raise error when a before_action's only/except options reference missing actions + config.action_controller.raise_on_missing_callback_actions = true end diff --git a/config/initializers/application_controller_renderer.rb b/config/initializers/application_controller_renderer.rb index f4556db3..6d56e439 100644 --- a/config/initializers/application_controller_renderer.rb +++ b/config/initializers/application_controller_renderer.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do diff --git a/config/initializers/content_security_policy.rb b/config/initializers/content_security_policy.rb index f3bcce54..2b189cc2 100644 --- a/config/initializers/content_security_policy.rb +++ b/config/initializers/content_security_policy.rb @@ -1,9 +1,10 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Define an application-wide content security policy -# For further information see the following documentation -# https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Security-Policy +# See the Securing Rails Applications Guide for more information: +# https://guides.rubyonrails.org/security.html#content-security-policy-header # Rails.application.config.content_security_policy do |policy| # policy.default_src :self, :https diff --git a/config/initializers/inflections.rb b/config/initializers/inflections.rb index aa7435fb..dc847422 100644 --- a/config/initializers/inflections.rb +++ b/config/initializers/inflections.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections diff --git a/config/initializers/new_framework_defaults_6_1.rb b/config/initializers/new_framework_defaults_6_1.rb index 0b4ce023..8c28549c 100644 --- a/config/initializers/new_framework_defaults_6_1.rb +++ b/config/initializers/new_framework_defaults_6_1.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 6.1 upgrade. diff --git a/config/initializers/new_framework_defaults_7_1.rb b/config/initializers/new_framework_defaults_7_1.rb new file mode 100644 index 00000000..ebedc26c --- /dev/null +++ b/config/initializers/new_framework_defaults_7_1.rb @@ -0,0 +1,282 @@ +# frozen_string_literal: true + +# Be sure to restart your server when you modify this file. +# +# This file eases your Rails 7.1 framework defaults upgrade. +# +# Uncomment each configuration one by one to switch to the new default. +# Once your application is ready to run with all new defaults, you can remove +# this file and set the `config.load_defaults` to `7.1`. +# +# Read the Guide for Upgrading Ruby on Rails for more info on each option. +# https://guides.rubyonrails.org/upgrading_ruby_on_rails.html + +### +# No longer add autoloaded paths into `$LOAD_PATH`. This means that you won't be able +# to manually require files that are managed by the autoloader, which you shouldn't do anyway. +# +# This will reduce the size of the load path, making `require` faster if you don't use bootsnap, or reduce the size +# of the bootsnap cache if you use it. +# +# To set this configuration, add the following line to `config/application.rb` (NOT this file): +# config.add_autoload_paths_to_load_path = false + +### +# Remove the default X-Download-Options headers since it is used only by Internet Explorer. +# If you need to support Internet Explorer, add back `"X-Download-Options" => "noopen"`. +#++ +# Rails.application.config.action_dispatch.default_headers = { +# "X-Frame-Options" => "SAMEORIGIN", +# "X-XSS-Protection" => "0", +# "X-Content-Type-Options" => "nosniff", +# "X-Permitted-Cross-Domain-Policies" => "none", +# "Referrer-Policy" => "strict-origin-when-cross-origin" +# } + +### +# Do not treat an `ActionController::Parameters` instance +# as equal to an equivalent `Hash` by default. +#++ +# Rails.application.config.action_controller.allow_deprecated_parameters_hash_equality = false + +### +# Active Record Encryption now uses SHA-256 as its hash digest algorithm. +# +# There are 3 scenarios to consider. +# +# 1. If you have data encrypted with previous Rails versions, and you have +# +config.active_support.key_generator_hash_digest_class+ configured as SHA1 (the default +# before Rails 7.0), you need to configure SHA-1 for Active Record Encryption too: +#++ +# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA1 +# +# 2. If you have +config.active_support.key_generator_hash_digest_class+ configured as SHA256 (the new default +# in 7.0), then you need to configure SHA-256 for Active Record Encryption: +#++ +# Rails.application.config.active_record.encryption.hash_digest_class = OpenSSL::Digest::SHA256 +# +# 3. If you don't currently have data encrypted with Active Record encryption, you can disable this setting to +# configure the default behavior starting 7.1+: +#++ +# Rails.application.config.active_record.encryption.support_sha1_for_non_deterministic_encryption = false + +### +# No longer run after_commit callbacks on the first of multiple Active Record +# instances to save changes to the same database row within a transaction. +# Instead, run these callbacks on the instance most likely to have internal +# state which matches what was committed to the database, typically the last +# instance to save. +#++ +# Rails.application.config.active_record.run_commit_callbacks_on_first_saved_instances_in_transaction = false + +### +# Configures SQLite with a strict strings mode, which disables double-quoted string literals. +# +# SQLite has some quirks around double-quoted string literals. +# It first tries to consider double-quoted strings as identifier names, but if they don't exist +# it then considers them as string literals. Because of this, typos can silently go unnoticed. +# For example, it is possible to create an index for a non existing column. +# See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted for more details. +#++ +# Rails.application.config.active_record.sqlite3_adapter_strict_strings_by_default = true + +### +# Disable deprecated singular associations names. +#++ +# Rails.application.config.active_record.allow_deprecated_singular_associations_name = false + +### +# Enable the Active Job `BigDecimal` argument serializer, which guarantees +# roundtripping. Without this serializer, some queue adapters may serialize +# `BigDecimal` arguments as simple (non-roundtrippable) strings. +# +# When deploying an application with multiple replicas, old (pre-Rails 7.1) +# replicas will not be able to deserialize `BigDecimal` arguments from this +# serializer. Therefore, this setting should only be enabled after all replicas +# have been successfully upgraded to Rails 7.1. +#++ +# Rails.application.config.active_job.use_big_decimal_serializer = true + +### +# Specify if an `ArgumentError` should be raised if `Rails.cache` `fetch` or +# `write` are given an invalid `expires_at` or `expires_in` time. +# Options are `true`, and `false`. If `false`, the exception will be reported +# as `handled` and logged instead. +#++ +# Rails.application.config.active_support.raise_on_invalid_cache_expiration_time = true + +### +# Specify whether Query Logs will format tags using the SQLCommenter format +# (https://open-telemetry.github.io/opentelemetry-sqlcommenter/), or using the legacy format. +# Options are `:legacy` and `:sqlcommenter`. +#++ +# Rails.application.config.active_record.query_log_tags_format = :sqlcommenter + +### +# Specify the default serializer used by `MessageEncryptor` and `MessageVerifier` +# instances. +# +# The legacy default is `:marshal`, which is a potential vector for +# deserialization attacks in cases where a message signing secret has been +# leaked. +# +# In Rails 7.1, the new default is `:json_allow_marshal` which serializes and +# deserializes with `ActiveSupport::JSON`, but can fall back to deserializing +# with `Marshal` so that legacy messages can still be read. +# +# In Rails 7.2, the default will become `:json` which serializes and +# deserializes with `ActiveSupport::JSON` only. +# +# Alternatively, you can choose `:message_pack` or `:message_pack_allow_marshal`, +# which serialize with `ActiveSupport::MessagePack`. `ActiveSupport::MessagePack` +# can roundtrip some Ruby types that are not supported by JSON, and may provide +# improved performance, but it requires the `msgpack` gem. +# +# For more information, see +# https://guides.rubyonrails.org/v7.1/configuring.html#config-active-support-message-serializer +# +# If you are performing a rolling deploy of a Rails 7.1 upgrade, wherein servers +# that have not yet been upgraded must be able to read messages from upgraded +# servers, first deploy without changing the serializer, then set the serializer +# in a subsequent deploy. +#++ +# Rails.application.config.active_support.message_serializer = :json_allow_marshal + +### +# Enable a performance optimization that serializes message data and metadata +# together. This changes the message format, so messages serialized this way +# cannot be read by older versions of Rails. However, messages that use the old +# format can still be read, regardless of whether this optimization is enabled. +# +# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have +# not yet been upgraded must be able to read messages from upgraded servers, +# leave this optimization off on the first deploy, then enable it on a +# subsequent deploy. +#++ +# Rails.application.config.active_support.use_message_serializer_for_metadata = true + +### +# Set the maximum size for Rails log files. +# +# `config.load_defaults 7.1` does not set this value for environments other than +# development and test. +#++ +# if Rails.env.local? +# Rails.application.config.log_file_size = 100 * 1024 * 1024 +# end + +### +# Enable raising on assignment to attr_readonly attributes. The previous +# behavior would allow assignment but silently not persist changes to the +# database. +#++ +# Rails.application.config.active_record.raise_on_assign_to_attr_readonly = true + +### +# Enable validating only parent-related columns for presence when the parent is mandatory. +# The previous behavior was to validate the presence of the parent record, which performed an extra query +# to get the parent every time the child record was updated, even when parent has not changed. +#++ +# Rails.application.config.active_record.belongs_to_required_validates_foreign_key = false + +### +# Enable precompilation of `config.filter_parameters`. Precompilation can +# improve filtering performance, depending on the quantity and types of filters. +#++ +# Rails.application.config.precompile_filter_parameters = true + +### +# Enable before_committed! callbacks on all enrolled records in a transaction. +# The previous behavior was to only run the callbacks on the first copy of a record +# if there were multiple copies of the same record enrolled in the transaction. +#++ +# Rails.application.config.active_record.before_committed_on_all_records = true + +### +# Disable automatic column serialization into YAML. +# To keep the historic behavior, you can set it to `YAML`, however it is +# recommended to explicitly define the serialization method for each column +# rather than to rely on a global default. +#++ +# Rails.application.config.active_record.default_column_serializer = nil + +### +# Enable a performance optimization that serializes Active Record models +# in a faster and more compact way. +# +# To perform a rolling deploy of a Rails 7.1 upgrade, wherein servers that have +# not yet been upgraded must be able to read caches from upgraded servers, +# leave this optimization off on the first deploy, then enable it on a +# subsequent deploy. +#++ +# Rails.application.config.active_record.marshalling_format_version = 7.1 + +### +# Run `after_commit` and `after_*_commit` callbacks in the order they are defined in a model. +# This matches the behaviour of all other callbacks. +# In previous versions of Rails, they ran in the inverse order. +#++ +# Rails.application.config.active_record.run_after_transaction_callbacks_in_order_defined = true + +### +# Whether a `transaction` block is committed or rolled back when exited via `return`, `break` or `throw`. +#++ +# Rails.application.config.active_record.commit_transaction_on_non_local_return = true + +### +# Controls when to generate a value for has_secure_token declarations. +#++ +# Rails.application.config.active_record.generate_secure_token_on = :initialize + +### +# ** Please read carefully, this must be configured in config/application.rb ** +# +# Change the format of the cache entry. +# +# Changing this default means that all new cache entries added to the cache +# will have a different format that is not supported by Rails 7.0 +# applications. +# +# Only change this value after your application is fully deployed to Rails 7.1 +# and you have no plans to rollback. +# When you're ready to change format, add this to `config/application.rb` (NOT +# this file): +# config.active_support.cache_format_version = 7.1 + +### +# Configure Action View to use HTML5 standards-compliant sanitizers when they are supported on your +# platform. +# +# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action View to use HTML5-compliant +# sanitizers if they are supported, else fall back to HTML4 sanitizers. +# +# In previous versions of Rails, Action View always used `Rails::HTML4::Sanitizer` as its vendor. +#++ +# Rails.application.config.action_view.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor + +### +# Configure Action Text to use an HTML5 standards-compliant sanitizer when it is supported on your +# platform. +# +# `Rails::HTML::Sanitizer.best_supported_vendor` will cause Action Text to use HTML5-compliant +# sanitizers if they are supported, else fall back to HTML4 sanitizers. +# +# In previous versions of Rails, Action Text always used `Rails::HTML4::Sanitizer` as its vendor. +#++ +# Rails.application.config.action_text.sanitizer_vendor = Rails::HTML::Sanitizer.best_supported_vendor + +### +# Configure the log level used by the DebugExceptions middleware when logging +# uncaught exceptions during requests. +#++ +# Rails.application.config.action_dispatch.debug_exception_log_level = :error + +### +# Configure the test helpers in Action View, Action Dispatch, and rails-dom-testing to use HTML5 +# parsers. +# +# Nokogiri::HTML5 isn't supported on JRuby, so JRuby applications must set this to :html4. +# +# In previous versions of Rails, these test helpers always used an HTML4 parser. +#++ +# Rails.application.config.dom_testing_default_html_version = :html5 diff --git a/config/initializers/permissions_policy.rb b/config/initializers/permissions_policy.rb index 50bcf4ea..810aadeb 100644 --- a/config/initializers/permissions_policy.rb +++ b/config/initializers/permissions_policy.rb @@ -1,4 +1,5 @@ # frozen_string_literal: true + # Define an application-wide HTTP permissions policy. For further # information see https://developers.google.com/web/updates/2018/06/feature-policy # diff --git a/config/locales/en.yml b/config/locales/en.yml index 1b9f76b5..c1c551fb 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -30,6 +30,15 @@ # available at https://guides.rubyonrails.org/i18n.html. en: + blacklight_advanced_search: + all: all + any: any + form: + title: More Search Options + query_criteria_heading_html: "Find items that match %{select_menu} of" + sort_label: "Sort results by" + start_over: "Start over" + search_btn: "Search" blackcat: successful_login: Successfully authenticated from Penn State account hathitrust: diff --git a/db/migrate/20240401150059_create_active_storage_variant_records.active_storage.rb b/db/migrate/20240401150059_create_active_storage_variant_records.active_storage.rb new file mode 100644 index 00000000..94ac83af --- /dev/null +++ b/db/migrate/20240401150059_create_active_storage_variant_records.active_storage.rb @@ -0,0 +1,27 @@ +# This migration comes from active_storage (originally 20191206030411) +class CreateActiveStorageVariantRecords < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + # Use Active Record's configured type for primary key + create_table :active_storage_variant_records, id: primary_key_type, if_not_exists: true do |t| + t.belongs_to :blob, null: false, index: false, type: blobs_primary_key_type + t.string :variation_digest, null: false + + t.index %i[ blob_id variation_digest ], name: "index_active_storage_variant_records_uniqueness", unique: true + t.foreign_key :active_storage_blobs, column: :blob_id + end + end + + private + def primary_key_type + config = Rails.configuration.generators + config.options[config.orm][:primary_key_type] || :primary_key + end + + def blobs_primary_key_type + pkey_name = connection.primary_key(:active_storage_blobs) + pkey_column = connection.columns(:active_storage_blobs).find { |c| c.name == pkey_name } + pkey_column.bigint? ? :bigint : pkey_column.type + end +end diff --git a/db/migrate/20240401150060_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb b/db/migrate/20240401150060_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb new file mode 100644 index 00000000..93c8b85a --- /dev/null +++ b/db/migrate/20240401150060_remove_not_null_on_active_storage_blobs_checksum.active_storage.rb @@ -0,0 +1,8 @@ +# This migration comes from active_storage (originally 20211119233751) +class RemoveNotNullOnActiveStorageBlobsChecksum < ActiveRecord::Migration[6.0] + def change + return unless table_exists?(:active_storage_blobs) + + change_column_null(:active_storage_blobs, :checksum, true) + end +end diff --git a/db/schema.rb b/db/schema.rb index 304e564e..df53f68b 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,14 +10,13 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 2023_05_11_165922) do - +ActiveRecord::Schema[7.1].define(version: 2024_04_01_150060) do create_table "active_storage_attachments", force: :cascade do |t| t.string "name", null: false t.string "record_type", null: false t.integer "record_id", null: false t.integer "blob_id", null: false - t.datetime "created_at", null: false + t.datetime "created_at", precision: nil, null: false t.index ["blob_id"], name: "index_active_storage_attachments_on_blob_id" t.index ["record_type", "record_id", "name", "blob_id"], name: "index_active_storage_attachments_uniqueness", unique: true end @@ -29,8 +28,8 @@ t.text "metadata" t.string "service_name", null: false t.bigint "byte_size", null: false - t.string "checksum", null: false - t.datetime "created_at", null: false + t.string "checksum" + t.datetime "created_at", precision: nil, null: false t.index ["key"], name: "index_active_storage_blobs_on_key", unique: true end @@ -46,8 +45,8 @@ t.string "document_id" t.string "document_type" t.binary "title" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.index ["document_id"], name: "index_bookmarks_on_document_id" t.index ["user_id"], name: "index_bookmarks_on_user_id" end @@ -56,8 +55,8 @@ t.binary "query_params" t.integer "user_id" t.string "user_type" - t.datetime "created_at", precision: 6, null: false - t.datetime "updated_at", precision: 6, null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false t.index ["user_id"], name: "index_searches_on_user_id" end @@ -65,15 +64,15 @@ t.string "email", default: "", null: false t.string "encrypted_password", default: "", null: false t.string "reset_password_token" - t.datetime "reset_password_sent_at" - t.datetime "remember_created_at" + t.datetime "reset_password_sent_at", precision: nil + t.datetime "remember_created_at", precision: nil t.integer "sign_in_count", default: 0, null: false - t.datetime "current_sign_in_at" - t.datetime "last_sign_in_at" + t.datetime "current_sign_in_at", precision: nil + t.datetime "last_sign_in_at", precision: nil t.string "current_sign_in_ip" t.string "last_sign_in_ip" - t.datetime "created_at", null: false - t.datetime "updated_at", null: false + t.datetime "created_at", precision: nil, null: false + t.datetime "updated_at", precision: nil, null: false t.boolean "guest", default: false t.index ["email"], name: "index_users_on_email", unique: true t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true diff --git a/lib/psulib_blacklight/solr_config.rb b/lib/psulib_blacklight/solr_config.rb index 5212f67a..b98e5aff 100644 --- a/lib/psulib_blacklight/solr_config.rb +++ b/lib/psulib_blacklight/solr_config.rb @@ -15,22 +15,22 @@ def url def query_url query_url = "#{url}/solr/#{collection_name}" if solr_username && solr_password - return query_url.gsub(/:\/\//, "://#{solr_username}:#{CGI.escape(solr_password)}@") + return query_url.gsub('://', "://#{solr_username}:#{CGI.escape(solr_password)}@") end query_url end def solr_username - Settings&.solr&.username + Settings.solr&.username end def solr_password - Settings&.solr&.password + Settings.solr&.password end def collection_name - Settings&.solr&.collection || 'blacklight-core' + Settings.solr&.collection || 'blacklight-core' end def alias_name @@ -38,15 +38,15 @@ def alias_name end def num_shards - Settings&.solr&.num_shards || 1 + Settings.solr&.num_shards || 1 end def replication_factor - Settings&.solr&.replication_factor || 1 + Settings.solr&.replication_factor || 1 end def max_shards_per_node - Settings&.solr&.max_shards_per_node || 1 + Settings.solr&.max_shards_per_node || 1 end def configset_name diff --git a/spec/components/browse/call_number_navigation_spec.rb b/spec/components/browse/call_number_navigation_spec.rb index c6e6da4d..8f9a6536 100644 --- a/spec/components/browse/call_number_navigation_spec.rb +++ b/spec/components/browse/call_number_navigation_spec.rb @@ -6,7 +6,9 @@ let(:node) { render_inline(described_class.new(list: mock_list)) } let(:mock_list) { instance_spy(ShelfListPresenter, previous_item: prev_item, next_item: next_item) } - before { controller.params = { length: 20, action: 'call_numbers', classification: classification } } + before { + allow_any_instance_of(described_class).to receive(:params).and_return({ length: 20, action: 'call_numbers', + classification: classification }) } context 'when Browse by LC Call Number' do let(:classification) { 'lc' } @@ -16,7 +18,7 @@ let(:prev_item) { nil } specify do - expect(node).not_to have_link('Previous') + expect(node).to have_no_link('Previous') expect(node).to have_link('Next', href: '/browse/call_numbers?classification=lc&length=20&starting=KEY1') end end @@ -27,7 +29,7 @@ specify do expect(node).to have_link('Previous', href: '/browse/call_numbers?classification=lc&ending=KEY2&length=20') - expect(node).not_to have_link('Next') + expect(node).to have_no_link('Next') end end @@ -46,8 +48,8 @@ let(:next_item) { nil } specify do - expect(node).not_to have_link('Previous') - expect(node).not_to have_link('Next') + expect(node).to have_no_link('Previous') + expect(node).to have_no_link('Next') end end end @@ -60,7 +62,7 @@ let(:prev_item) { nil } specify do - expect(node).not_to have_link('Previous') + expect(node).to have_no_link('Previous') expect(node).to have_link('Next', href: '/browse/call_numbers?classification=dewey&length=20&starting=KEY1') end end @@ -71,7 +73,7 @@ specify do expect(node).to have_link('Previous', href: '/browse/call_numbers?classification=dewey&ending=KEY2&length=20') - expect(node).not_to have_link('Next') + expect(node).to have_no_link('Next') end end @@ -90,8 +92,8 @@ let(:next_item) { nil } specify do - expect(node).not_to have_link('Previous') - expect(node).not_to have_link('Next') + expect(node).to have_no_link('Previous') + expect(node).to have_no_link('Next') end end end diff --git a/spec/components/browse/call_number_toggle_list_spec.rb b/spec/components/browse/call_number_toggle_list_spec.rb index ea892996..5bb4bec0 100644 --- a/spec/components/browse/call_number_toggle_list_spec.rb +++ b/spec/components/browse/call_number_toggle_list_spec.rb @@ -11,7 +11,7 @@ let (:node) { render_inline(instance) } it 'renders the component and all links' do - expect(node).to have_selector('#moreCallNumbers123') + expect(node).to have_css('#moreCallNumbers123') expect(node).to have_link('ABC', href: '/catalog/123') expect(node).to have_link('DEF', href: '/catalog/123') end diff --git a/spec/components/browse/call_number_toggle_spec.rb b/spec/components/browse/call_number_toggle_spec.rb index 2eecb162..46470d79 100644 --- a/spec/components/browse/call_number_toggle_spec.rb +++ b/spec/components/browse/call_number_toggle_spec.rb @@ -11,7 +11,7 @@ let (:node) { render_inline(instance) } it 'renders the component' do - expect(node).to have_selector('#moreCallNumbers123Btn') + expect(node).to have_css('#moreCallNumbers123Btn') end end diff --git a/spec/components/browse/facet_navigation_spec.rb b/spec/components/browse/facet_navigation_spec.rb index a711dc0b..40a15c12 100644 --- a/spec/components/browse/facet_navigation_spec.rb +++ b/spec/components/browse/facet_navigation_spec.rb @@ -12,19 +12,18 @@ before do allow(browse_list).to receive(:last_page?).and_return(false) + allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'authors' }) end context 'when browsing authors' do - before { controller.params = { action: 'authors' } } - - it { is_expected.not_to have_link('Previous') } + it { is_expected.to have_no_link('Previous') } it { is_expected.to have_link('Next', href: '/browse/authors?length=10&page=2') } end context 'when browsing subjects' do - before { controller.params = { action: 'subjects' } } + before { allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'subjects' }) } - it { is_expected.not_to have_link('Previous') } + it { is_expected.to have_no_link('Previous') } it { is_expected.to have_link('Next', href: '/browse/subjects?length=10&page=2') } end end @@ -33,17 +32,21 @@ let(:browse_list) { instance_spy(BrowseList, page: 5, length: 10, entries: [entry]) } context 'when browsing authors' do - before { controller.params = { action: 'authors' } } + before do + allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'authors' }) + end it { is_expected.to have_link('Previous', href: '/browse/authors?length=10&page=4') } - it { is_expected.not_to have_link('Next') } + it { is_expected.to have_no_link('Next') } end context 'when browsing subjects' do - before { controller.params = { action: 'subjects' } } + before do + allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'subjects' }) + end it { is_expected.to have_link('Previous', href: '/browse/subjects?length=10&page=4') } - it { is_expected.not_to have_link('Next') } + it { is_expected.to have_no_link('Next') } end end @@ -52,17 +55,18 @@ before do allow(browse_list).to receive(:last_page?).and_return(false) + allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'subjects' }) end context 'when browsing authors' do - before { controller.params = { action: 'authors' } } + before { allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'authors' }) } it { is_expected.to have_link('Previous', href: '/browse/authors?length=10&page=2') } it { is_expected.to have_link('Next', href: '/browse/authors?length=10&page=4') } end context 'when browsing subjects' do - before { controller.params = { action: 'subjects' } } + before { allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'subjects' }) } it { is_expected.to have_link('Previous', href: '/browse/subjects?length=10&page=2') } it { is_expected.to have_link('Next', href: '/browse/subjects?length=10&page=4') } diff --git a/spec/components/browse/nearby_button_spec.rb b/spec/components/browse/nearby_button_spec.rb index 1587d4ae..0e3f0ebb 100644 --- a/spec/components/browse/nearby_button_spec.rb +++ b/spec/components/browse/nearby_button_spec.rb @@ -10,7 +10,7 @@ let(:classification) { 'lc' } it 'renders a simple button' do - expect(node).not_to have_selector('button[data-toggle=dropdown]') + expect(node).to have_no_css('button[data-toggle=dropdown]') expect(node).to have_link('Browse Nearby on Shelf', href: '/browse/call_numbers?classification=lc&nearby=ABC') end end @@ -20,7 +20,7 @@ let(:classification) { 'dewey' } it 'renders a simple button' do - expect(node).not_to have_selector('button[data-toggle=dropdown]') + expect(node).to have_no_css('button[data-toggle=dropdown]') expect(node).to have_link('Browse Nearby on Shelf', href: '/browse/call_numbers?classification=dewey&nearby=131') end end @@ -30,7 +30,7 @@ let(:classification) { 'lc' } it 'renders a dropdown button with multiple options' do - expect(node).to have_selector('button[data-toggle=dropdown]') + expect(node).to have_css('button[data-toggle=dropdown]') expect(node).to have_link('ABC', href: '/browse/call_numbers?classification=lc&nearby=ABC') expect(node).to have_link('DEF', href: '/browse/call_numbers?classification=lc&nearby=DEF') end @@ -41,7 +41,7 @@ let(:classification) { 'dewey' } it 'renders a dropdown button with multiple options' do - expect(node).to have_selector('button[data-toggle=dropdown]') + expect(node).to have_css('button[data-toggle=dropdown]') expect(node).to have_link('131', href: '/browse/call_numbers?classification=dewey&nearby=131') expect(node).to have_link('132', href: '/browse/call_numbers?classification=dewey&nearby=132') end diff --git a/spec/components/browse/page_size_selector_spec.rb b/spec/components/browse/page_size_selector_spec.rb index dd52430e..c37c087a 100644 --- a/spec/components/browse/page_size_selector_spec.rb +++ b/spec/components/browse/page_size_selector_spec.rb @@ -15,7 +15,7 @@ end context 'when there is no corresponding path method for the action' do - before { controller.params = { action: 'bogus' } } + before { allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'bogus' }) } specify do expect { @@ -25,7 +25,8 @@ end describe 'call number page selectors' do - before { controller.params = { nearby: 'abc', action: 'call_numbers' } } + before { + allow_any_instance_of(described_class).to receive(:params).and_return({ nearby: 'abc', action: 'call_numbers' }) } context 'when the length param is not provided' do specify do @@ -34,7 +35,8 @@ end context 'when the length param is explicitly provided' do - before { controller.params = { length: 50, action: 'call_numbers' } } + before { + allow_any_instance_of(described_class).to receive(:params).and_return({ length: 50, action: 'call_numbers' }) } specify do expect(button.text).to include('50 per page') @@ -49,7 +51,7 @@ end describe 'subject page selectors' do - before { controller.params = { action: 'subjects' } } + before { allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'subjects' }) } context 'when the length param is not provided' do specify do @@ -58,7 +60,8 @@ end context 'when the length param is explicitly provided' do - before { controller.params = { length: 50, action: 'subjects' } } + before { + allow_any_instance_of(described_class).to receive(:params).and_return({ length: 50, action: 'subjects' }) } specify do expect(button.text).to include('50 per page') diff --git a/spec/components/browse/prefix_selector_spec.rb b/spec/components/browse/prefix_selector_spec.rb index f6ae8890..d1c75eb9 100644 --- a/spec/components/browse/prefix_selector_spec.rb +++ b/spec/components/browse/prefix_selector_spec.rb @@ -14,7 +14,7 @@ end context 'when there is no corresponding path method for the action' do - before { controller.params = { action: 'bogus' } } + before { allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'bogus' }) } specify do expect { @@ -24,11 +24,11 @@ end context 'when no prefix is specified' do - before { controller.params = { action: 'subjects' } } + before { allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'subjects' }) } it "renders the selectors with 'All' active" do expect(node.css('li.active').count).to eq(1) - expect(node).to have_selector('li', class: 'active', text: 'All') + expect(node).to have_css('li', class: 'active', text: 'All') ('A'..'Z').to_a.each do |letter| expect(node).to have_link(letter) @@ -39,16 +39,17 @@ context 'with a specified prefix' do let(:node) { render_inline(described_class.new(prefix: 'E')) } - before { controller.params = { action: 'subjects' } } + before { allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'subjects' }) } it 'renders the selector as active' do expect(node.css('li.active').count).to eq(1) - expect(node).to have_selector('li', class: 'active', text: 'E') + expect(node).to have_css('li', class: 'active', text: 'E') end end context 'when length is present as a parameter' do - before { controller.params = { action: 'subjects', length: '20' } } + before { + allow_any_instance_of(described_class).to receive(:params).and_return({ action: 'subjects', length: '20' }) } it 'retains the parameter in the urls' do ('A'..'Z').to_a.each do |letter| diff --git a/spec/components/external_links/base_links_component.html.erb_spec.rb b/spec/components/external_links/base_links_component.html.erb_spec.rb index 8e98e0ed..318cf7d4 100644 --- a/spec/components/external_links/base_links_component.html.erb_spec.rb +++ b/spec/components/external_links/base_links_component.html.erb_spec.rb @@ -24,7 +24,7 @@ } it 'renders the heading correctly' do - expect(rendered).to have_selector 'h5', text: 'External Links' + expect(rendered).to have_css 'h5', text: 'External Links' end context 'when are less than 3 links of the same type' do @@ -36,11 +36,11 @@ end it 'does not display a view more button' do - expect(rendered).not_to have_selector '.toggle-external-links' + expect(rendered).to have_no_css '.toggle-external-links' end it 'does not collapse any links' do - expect(rendered).not_to have_selector('#collapseLinksExternalLinks') + expect(rendered).to have_no_css('#collapseLinksExternalLinks') end end @@ -67,7 +67,7 @@ } it 'displays a view more button' do - expect(rendered).to have_selector '.toggle-external-links.collapsed' + expect(rendered).to have_css '.toggle-external-links.collapsed' end it 'displays 2 links and collapses the rest' do @@ -105,11 +105,11 @@ end it 'does not display a view more button' do - expect(rendered).not_to have_selector '.toggle-external-links' + expect(rendered).to have_no_css '.toggle-external-links' end it 'does not collapse any links' do - expect(rendered).not_to have_selector('#collapseLinksExternalLinks') + expect(rendered).to have_no_css('#collapseLinksExternalLinks') end end end diff --git a/spec/components/external_links/hathi_links_component.html.erb_spec.rb b/spec/components/external_links/hathi_links_component.html.erb_spec.rb index 179a5a30..3f1f0bb6 100644 --- a/spec/components/external_links/hathi_links_component.html.erb_spec.rb +++ b/spec/components/external_links/hathi_links_component.html.erb_spec.rb @@ -25,7 +25,7 @@ expect(rendered).to have_link(href: 'https://catalog.hathitrust.org/Record/12345') .and have_css("img[src*='HathiTrust_logo']") .and have_text(I18n.t!('blackcat.hathitrust.public_domain_text')) - expect(rendered).not_to have_content(I18n.t!('blackcat.hathitrust.etas_additional_text')) + expect(rendered).to have_no_content(I18n.t!('blackcat.hathitrust.etas_additional_text')) end end diff --git a/spec/components/psul_constraint_layout_component_spec.rb b/spec/components/psul_constraint_layout_component_spec.rb index 13e6e736..9870f972 100644 --- a/spec/components/psul_constraint_layout_component_spec.rb +++ b/spec/components/psul_constraint_layout_component_spec.rb @@ -13,16 +13,16 @@ end it 'renders label and value' do - expect(rendered).to have_selector('span.applied-filter.constraint') + expect(rendered).to have_css('span.applied-filter.constraint') expect(rendered).to have_css('span.constraint-value') - expect(rendered).not_to have_css('a.constraint-value') - expect(rendered).not_to have_css('span.btn.btn-outline-secondary.constraint-value') - expect(rendered).to have_selector 'span.filter-name', text: 'my label' - expect(rendered).to have_selector 'span.filter-value', text: 'my value' + expect(rendered).to have_no_css('a.constraint-value') + expect(rendered).to have_no_css('span.btn.btn-outline-secondary.constraint-value') + expect(rendered).to have_css 'span.filter-name', text: 'my label' + expect(rendered).to have_css 'span.filter-value', text: 'my value' end it 'not a button group' do - expect(rendered).not_to have_selector('span.btn-group.applied-filter.constraint') + expect(rendered).to have_no_css('span.btn-group.applied-filter.constraint') end end @@ -32,21 +32,21 @@ end it 'includes remove link' do - expect(rendered).to have_selector('span.applied-filter') do |s| - expect(s).to have_selector(".remove[href='http://remove']") + expect(rendered).to have_css('span.applied-filter') do |s| + expect(s).to have_css(".remove[href='http://remove']") end end it 'has an accessible remove label' do - expect(rendered).to have_selector('.remove') do |s| - expect(s).to have_selector('.sr-only', text: 'Remove constraint my label: my value') + expect(rendered).to have_css('.remove') do |s| + expect(s).to have_css('.sr-only', text: 'Remove constraint my label: my value') end end it 'not a button group' do - expect(rendered).to have_selector('span.applied-filter') do |s| + expect(rendered).to have_css('span.applied-filter') do |s| expect(s).to have_css('a.remove') - expect(s).not_to have_css('a.btn.btn-outline-secondary') + expect(s).to have_no_css('a.btn.btn-outline-secondary') end end end diff --git a/spec/components/psul_constraints_component_spec.rb b/spec/components/psul_constraints_component_spec.rb index 83439cc3..06fb4678 100644 --- a/spec/components/psul_constraints_component_spec.rb +++ b/spec/components/psul_constraints_component_spec.rb @@ -21,10 +21,10 @@ end it 'renders constraints container' do - expect(rendered).to have_selector('div.constraints-container') + expect(rendered).to have_css('div.constraints-container') end it 'does not render a start over link' do - expect(rendered).not_to have_link('Start Over') + expect(rendered).to have_no_link('Start Over') end end diff --git a/spec/controllers/bento_controller_spec.rb b/spec/controllers/bento_controller_spec.rb index cf1345b5..8faa5d4f 100644 --- a/spec/controllers/bento_controller_spec.rb +++ b/spec/controllers/bento_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe BentoController, type: :controller do +RSpec.describe BentoController do describe '#index' do context 'when an html format request comes in' do it 'responds with unsupported media type' do @@ -14,7 +14,7 @@ context 'when it returns json' do render_views - let(:json_response) { JSON.parse(response.body) } + let(:json_response) { response.parsed_body } before do get :index, params: { format: :json, utf8: '✓', q: 'green', per_page: '3' } diff --git a/spec/controllers/bookmarks_controller_spec.rb b/spec/controllers/bookmarks_controller_spec.rb index d3886457..0c66c71b 100644 --- a/spec/controllers/bookmarks_controller_spec.rb +++ b/spec/controllers/bookmarks_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe BookmarksController, type: :controller do +RSpec.describe BookmarksController do describe 'GET #bulk_ris' do let(:expected_content_type) { 'application/x-research-info-systems' } let(:expected_file_name) { 'document.ris' } diff --git a/spec/controllers/browse_controller_spec.rb b/spec/controllers/browse_controller_spec.rb index 11b83348..5b6859ee 100644 --- a/spec/controllers/browse_controller_spec.rb +++ b/spec/controllers/browse_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe BrowseController, type: :controller do +RSpec.describe BrowseController do describe 'GET #call_numbers' do subject { response } diff --git a/spec/controllers/catalog_controller_spec.rb b/spec/controllers/catalog_controller_spec.rb index 90380a46..1dfc6ac4 100644 --- a/spec/controllers/catalog_controller_spec.rb +++ b/spec/controllers/catalog_controller_spec.rb @@ -2,13 +2,8 @@ require 'rails_helper' -RSpec.describe CatalogController, type: :controller do +RSpec.describe CatalogController do describe 'index action' do - it 'gets the homepage and renders only the homepage facets' do - get :index - configured_home_page_facets = %w[access_facet format campus_facet media_type_facet classification_pivot_field] - expect(assigns(:blacklight_config)[:facet_fields].keys).to eq(configured_home_page_facets) - end it 'pages too deep' do get :index, params: { page: 251 } diff --git a/spec/controllers/sitemap_controller_spec.rb b/spec/controllers/sitemap_controller_spec.rb index 6d80fbfd..5618e120 100644 --- a/spec/controllers/sitemap_controller_spec.rb +++ b/spec/controllers/sitemap_controller_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe SitemapController, type: :controller do +RSpec.describe SitemapController do describe 'calculations and responses from solr' do let(:sitemap) { described_class.new } diff --git a/spec/features/advanced_search_spec.rb b/spec/features/advanced_search_spec.rb index b49e0ec6..19ccacdb 100644 --- a/spec/features/advanced_search_spec.rb +++ b/spec/features/advanced_search_spec.rb @@ -2,87 +2,91 @@ require 'rails_helper' -RSpec.describe 'Advanced Search', type: :feature do - describe 'User uses advanced search', js: true do +RSpec.describe 'Advanced Search' do + describe 'User uses advanced search', :js do before do visit '/advanced' end + it 'renders an additional search button at the top of the form' do + expect(page).to have_css 'form h1.page-header input#advanced-search-submit-top' + end + context 'when doing single term searches' do context 'when searching by series title' do before do - fill_in 'series', with: 'Yale studies in political science' - click_button 'advanced-search-submit' + fill_in 'clause_5_query', with: 'Yale studies in political science' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="1373276"]' + expect(page).to have_css 'article[data-document-id="1373276"]' end end context 'when searching by series keyword' do before do - fill_in 'series', with: 'political science' - click_button 'advanced-search-submit' + fill_in 'clause_5_query', with: 'political science' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="1373276"]' + expect(page).to have_css 'article[data-document-id="1373276"]' end end context 'when searching by isbn' do before do - fill_in 'identifiers', with: '9780442290917' - click_button 'advanced-search-submit' + fill_in 'clause_4_query', with: '9780442290917' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="1069788"]' + expect(page).to have_css 'article[data-document-id="1069788"]' end end context 'when searching by issn' do before do - fill_in 'identifiers', with: '10756787' - click_button 'advanced-search-submit' + fill_in 'clause_4_query', with: '10756787' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="1443986"]' + expect(page).to have_css 'article[data-document-id="1443986"]' end end context 'when searching by LCCN' do before do - fill_in 'identifiers', with: '2001270122' - click_button 'advanced-search-submit' + fill_in 'clause_4_query', with: '2001270122' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="2250425"]' + expect(page).to have_css 'article[data-document-id="2250425"]' end end context 'when searching by publisher' do before do - fill_in 'publisher', with: 'Norton' - click_button 'advanced-search-submit' + fill_in 'clause_6_query', with: 'Norton' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="2069311"]' + expect(page).to have_css 'article[data-document-id="2069311"]' end end context 'when searching by a single publication date' do before do fill_in 'range_pub_date_itsi_begin', with: '2017' - click_button 'advanced-search-submit' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="31805602"]' + expect(page).to have_css 'article[data-document-id="31805602"]' end end @@ -90,12 +94,12 @@ before do fill_in 'range_pub_date_itsi_begin', with: '2017' fill_in 'range_pub_date_itsi_end', with: '2018' - click_button 'advanced-search-submit' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="31805602"]' - expect(page).to have_selector 'article[data-document-id="31805615"]' + expect(page).to have_css 'article[data-document-id="31805602"]' + expect(page).to have_css 'article[data-document-id="31805615"]' end end end @@ -103,36 +107,36 @@ context 'when doing combination searches' do context 'when searching for a specific book about quilts in Cumberland County' do before do - fill_in 'title', with: 'quilts cumberland' - fill_in 'author', with: 'quilters' + fill_in 'clause_1_query', with: 'quilts cumberland' + fill_in 'clause_2_query', with: 'quilters' find('button[data-id="access_facet"]').click - find('#bs-select-1-1').click + find_by_id('bs-select-1-1').click find('button[data-id="format"]').click - find('#bs-select-2-3').click + find_by_id('bs-select-2-3').click find('button[data-id="language_facet"]').click - find('#bs-select-3-4').click + find_by_id('bs-select-3-4').click find('button[data-id="lc_1letter_facet"]').click - find('#bs-select-5-12').click - click_button 'advanced-search-submit' + find_by_id('bs-select-5-12').click + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="18648055"]' + expect(page).to have_css 'article[data-document-id="18648055"]' end end context 'when searching for a specific book on geological perspectives of climate change' do before do - fill_in 'subject', with: 'Climatology' - fill_in 'series', with: 'AAPG studies in geology' - fill_in 'publisher', with: 'Petroleum Geologists' + fill_in 'clause_3_query', with: 'Climatology' + fill_in 'clause_5_query', with: 'AAPG studies in geology' + fill_in 'clause_6_query', with: 'Petroleum Geologists' find('button[data-id="library_facet"]').click - find('#bs-select-6-4').click - click_button 'advanced-search-submit' + find_by_id('bs-select-6-4').click + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="2250425"]' + expect(page).to have_css 'article[data-document-id="2250425"]' end end end @@ -140,23 +144,23 @@ context 'when using vernacular language' do context 'when searching in simplified chinese' do before do - fill_in 'title', with: '上海理论' - click_button 'advanced-search-submit' + fill_in 'clause_1_query', with: '上海理论' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="17280643"]' + expect(page).to have_css 'article[data-document-id="17280643"]' end end context 'when searching in traditional chinese' do before do - fill_in 'title', with: '上海理論' - click_button 'advanced-search-submit' + fill_in 'clause_1_query', with: '上海理論' + click_on 'advanced-search-submit' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="17280643"]' + expect(page).to have_css 'article[data-document-id="17280643"]' end end end diff --git a/spec/features/announcement_spec.rb b/spec/features/announcement_spec.rb index 2d15649c..f9fc0e74 100644 --- a/spec/features/announcement_spec.rb +++ b/spec/features/announcement_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Announcement', type: :feature, js: true do +RSpec.describe 'Announcement', :js do context 'when hide_announcement is enabled' do before do Settings.add_source!( @@ -16,7 +16,7 @@ it 'does not display an announcement on top' do visit root_path - expect(page).not_to have_css '.announcement' + expect(page).to have_no_css '.announcement' end end diff --git a/spec/features/ask_a_librarian_spec.rb b/spec/features/ask_a_librarian_spec.rb index d2c2016c..05e5fe7c 100644 --- a/spec/features/ask_a_librarian_spec.rb +++ b/spec/features/ask_a_librarian_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' -RSpec.describe 'Ask a librarian', type: :feature do - describe 'side tab widget', js: true do +RSpec.describe 'Ask a librarian' do + describe 'side tab widget', :js do before do stub_request(:any, /hathitrust/).to_return(status: 200, body: '{}', headers: {}) user = User.new(email: 'user1234@psu.edu') @@ -17,7 +17,7 @@ it 'shows up on a catalog item page only once after going to MARC View and back' do visit '/catalog/22090269' - click_link 'View MARC record' + click_on 'View MARC record' page.assert_selector('h1', text: 'MARC View', wait: 10) page.driver.go_back page.assert_selector('h1', diff --git a/spec/features/availability_spec.rb b/spec/features/availability_spec.rb index 63425103..15bf8b3b 100644 --- a/spec/features/availability_spec.rb +++ b/spec/features/availability_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require 'support/vcr' -RSpec.describe 'Availability', :vcr, type: :feature do +RSpec.describe 'Availability', :vcr do let(:hold_button_url) { "#{Settings.my_account_url}#{Settings.hold_button_path}" } before do @@ -13,7 +13,7 @@ Settings.hide_etas_holdings = false end - describe 'User searches for a record', js: true do + describe 'User searches for a record', :js do it 'that has holdings and a \'View Availability\' button' do visit '/?utf8=✓&search_field=all_fields&q=9781599901091' expect(page).to have_css 'button[data-target="#availability-5112336"]' @@ -45,17 +45,17 @@ it 'and clicks the \'View Availability\' button to display and hide holdings' do visit '/?utf8=✓&search_field=all_fields&q=9781599901091' expect(page).to have_css 'button[data-target="#availability-5112336"]' - expect(page).not_to have_css '#availability-5112336' - click_button('View Availability') - expect(page).not_to have_css '.availability-5112336', wait: 3 + expect(page).to have_no_css '#availability-5112336' + click_on('View Availability') + expect(page).to have_no_css '.availability-5112336', wait: 3 expect(page).to have_content 'PZ8.G3295Su 2008' expect(page).to have_content 'Fiction G4672sun 2008' end it 'that is an online resource and has no holdings to display' do visit '/?utf8=✓&search_field=all_fields&q=D-humanos+Arruti%2C+Mariana' - expect(page).not_to have_css 'button[data-target="#availability-22091400"]' - expect(page).not_to have_css '#availability-22091400' + expect(page).to have_no_css 'button[data-target="#availability-22091400"]' + expect(page).to have_no_css '#availability-22091400' end it 'that is an online resource and all copies are on order' do @@ -66,19 +66,19 @@ it 'that has a public note' do visit '/?utf8=✓&search_field=all_fields&q=6962697' - click_button('View Availability') + click_on('View Availability') expect(page).to have_css 'i.fa-info-circle[data-toggle="tooltip"][data-original-title="Struwwelpeter"]' end it 'that does NOT have a public note' do visit '/?utf8=✓&search_field=all_fields&q=2422046' - click_button('View Availability') - expect(page).not_to have_css 'i.fa-info-circle[data-toggle="tooltip"]' + click_on('View Availability') + expect(page).to have_no_css 'i.fa-info-circle[data-toggle="tooltip"]' end it 'that has summary holdings information' do visit '/?utf8=✓&search_field=all_fields&q=1793712' - click_button('View Availability') + click_on('View Availability') expect(page).to have_css 'tr.table-primary .h6', text: 'Stacks - General Collection: Holdings Summary' end @@ -90,11 +90,11 @@ it 'an etas record displays the \'View Availability\' button but hides the hold button' do visit '/?search_field=all_fields&q=Yidishe+bleter+in+Amerike' expect(page).to have_css 'button[data-target="#availability-3753687"]' - expect(page).not_to have_css '#availability-3753687' - click_button('View Availability') - expect(page).not_to have_css '.availability-3753687', wait: 3 + expect(page).to have_no_css '#availability-3753687' + click_on('View Availability') + expect(page).to have_no_css '.availability-3753687', wait: 3 expect(page).to have_content 'PN4885.Y5C5 1946' - expect(page).not_to have_link( + expect(page).to have_no_link( 'I Want It', href: "#{hold_button_url}3753687" ) end @@ -107,7 +107,7 @@ it "an etas record does not display 'View Availability' button even though there are holdable items" do skip "This record doesn't seem to be ETAS anymore, so availability is showing when it shouldn't" visit '/?search_field=all_fields&q=Yidishe+bleter+in+Amerike' - expect(page).not_to have_css 'button[data-target="#availability-3753687"]' + expect(page).to have_no_css 'button[data-target="#availability-3753687"]' end end end @@ -116,9 +116,9 @@ it 'an etas record displays \'View Availability\' button and hold button' do visit '/?search_field=all_fields&q=Yidishe+bleter+in+Amerike' expect(page).to have_css 'button[data-target="#availability-3753687"]' - expect(page).not_to have_css '#availability-3753687' - click_button('View Availability') - expect(page).not_to have_css '.availability-3753687', wait: 3 + expect(page).to have_no_css '#availability-3753687' + click_on('View Availability') + expect(page).to have_no_css '.availability-3753687', wait: 3 expect(page).to have_content 'PN4885.Y5C5 1946' expect(page).to have_link( 'I Want It', href: "#{hold_button_url}3753687" @@ -130,8 +130,8 @@ it 'hides the hold button' do visit '/?search_field=all_fields&q=Employment+law' expect(page).to have_css 'button[data-target="#availability-9186426"]' - click_button('View Availability') - expect(page).not_to have_link( + click_on('View Availability') + expect(page).to have_no_link( 'I Want It', href: "#{hold_button_url}9186426" ) end @@ -141,7 +141,7 @@ it 'displays the hold button' do visit '/?search_field=all_fields&q=+40+short+stories+%3A+a+portable+anthology' expect(page).to have_css 'button[data-target="#availability-23783767"]' - click_button('View Availability') + click_on('View Availability') expect(page).to have_link( 'I Want It', href: "#{hold_button_url}23783767" ) @@ -149,7 +149,7 @@ end end - describe 'User visits catalog record page', js: true do + describe 'User visits catalog record page', :js do it 'that has holdings to display' do visit '/catalog/370199' expect(page).to have_css 'div[class="availability"][data-keys="370199"]' @@ -158,7 +158,7 @@ it 'that is an online resource and has no holdings to display' do visit '/catalog/22091400' - expect(page).not_to have_css 'div[class="availability"]' + expect(page).to have_no_css 'div[class="availability"]' end it 'that is an online resource and all copies are on order' do @@ -174,7 +174,7 @@ it 'that does NOT have a public note' do visit '/?utf8=✓&search_field=all_fields&q=2422046' - expect(page).not_to have_css 'i.fa-info-circle[data-toggle="tooltip"]' + expect(page).to have_no_css 'i.fa-info-circle[data-toggle="tooltip"]' end it 'that has an item on course reserve' do @@ -208,7 +208,7 @@ it 'an etas record does not display holdings even though there are holdable items' do skip "This record doesn't seem to be ETAS anymore, so availability is showing when it shouldn't" visit '/catalog/3753687' - expect(page).not_to have_css 'div[class="availability"][data-keys="3753687"]' + expect(page).to have_no_css 'div[class="availability"][data-keys="3753687"]' end end end @@ -225,11 +225,11 @@ visit '/catalog/1793712' within 'div[data-library="UP-PAT"]' do expect(page).to have_css 'button', text: /View More/ - expect(page).not_to have_css 'button', text: /View Less/ + expect(page).to have_no_css 'button', text: /View Less/ expect(page).to have_xpath './/tbody/tr', count: 6 - click_button('View More') + click_on('View More') expect(page).to have_xpath './/tbody/tr', count: 79 - expect(page).not_to have_css 'button', text: /View More/ + expect(page).to have_no_css 'button', text: /View More/ end end end @@ -237,7 +237,7 @@ describe 'Archival Material:' do it 'has a "Request Material" link so it can be requested through Aeon' do visit '/catalog/1836205' - click_button('View More') + click_on('View More') sleep 1 # It seems to be taking a little longer to expand this list than it used to expect(page).to have_link( 'Request Material', @@ -303,7 +303,7 @@ it 'does not display even for a record with holdable items' do visit '/catalog/21588551' - expect(page).not_to have_link( + expect(page).to have_no_link( 'I Want It', href: "#{hold_button_url}21588551" ) end @@ -321,7 +321,7 @@ it 'does not display when a record has no holdable items' do visit '/catalog/107' - expect(page).not_to have_link( + expect(page).to have_no_link( 'I Want It', href: "#{hold_button_url}107" ) end @@ -334,7 +334,7 @@ it 'does not display for an etas record even with holdable items' do visit '/catalog/3753687' - expect(page).not_to have_link( + expect(page).to have_no_link( 'I Want It', href: "#{hold_button_url}3753687" ) end @@ -352,7 +352,7 @@ context 'when all items are on course reserves' do it 'hides the hold button' do visit '/catalog/9186426' - expect(page).not_to have_link( + expect(page).to have_no_link( 'I Want It', href: "#{hold_button_url}9186426" ) end @@ -398,7 +398,7 @@ context 'when all items are on course reserves' do it 'hides the hold button' do visit '/catalog/29252445' - expect(page).not_to have_link( + expect(page).to have_no_link( 'I Want It', href: "#{hold_button_url}29252445" ) end @@ -425,9 +425,9 @@ visit '/catalog/25095210' within 'div[data-library="UP-MAPS"]' do expect(page).to have_xpath './/tbody/tr[td//text()[contains(., \'Request scan\')]]', count: 4 - click_button('View More') + click_on('View More') expect(page).to have_xpath './/tbody/tr[td//text()[contains(., \'Request scan\')]]', count: 50 - expect(page).not_to have_css 'button', text: /View More/ + expect(page).to have_no_css 'button', text: /View More/ end end end diff --git a/spec/features/availability_tooltip_spec.rb b/spec/features/availability_tooltip_spec.rb index e244fc35..aea4f3af 100644 --- a/spec/features/availability_tooltip_spec.rb +++ b/spec/features/availability_tooltip_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require 'support/vcr' -RSpec.describe 'Availability Tooltip', :vcr, type: :feature do +RSpec.describe 'Availability Tooltip', :vcr do before do Settings.hathi_etas = false Settings.readonly = false @@ -11,10 +11,10 @@ Settings.hide_etas_holdings = false end - describe 'Clicking "View More" and hovering over tooltip', js: true do + describe 'Clicking "View More" and hovering over tooltip', :js do it 'renders tooltip' do visit '/catalog/2169033' - click_button 'View More' + click_on 'View More' sleep(0.5) find('i[data-toggle="tooltip"]').hover expect(find('i[aria-describedby^="tooltip"]')).to be_present diff --git a/spec/features/basic_search_spec.rb b/spec/features/basic_search_spec.rb index 09e0e83c..73ef581c 100644 --- a/spec/features/basic_search_spec.rb +++ b/spec/features/basic_search_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' -RSpec.describe 'Basic Search', type: :feature do - describe 'User uses basic search', js: true do +RSpec.describe 'Basic Search' do + describe 'User uses basic search', :js do context 'when searching by title' do before do visit '/?search_field=title&q=' @@ -12,56 +12,56 @@ context 'when searching by title' do before do fill_in 'q', with: 'Becoming' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="24053587"]' - expect(page).to have_selector 'article[data-document-id="3626147"]' + expect(page).to have_css 'article[data-document-id="24053587"]' + expect(page).to have_css 'article[data-document-id="3626147"]' end end context 'when searching by title series without quotes' do before do fill_in 'q', with: 'IEEE standards' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="2290006"]' + expect(page).to have_css 'article[data-document-id="2290006"]' end end context 'when searching by alternate title' do before do fill_in 'q', with: 'Blind swordsman' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="12133574"]' + expect(page).to have_css 'article[data-document-id="12133574"]' end end context 'when searching by former title' do before do fill_in 'q', with: 'Washington post and times herald' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="114189"]' + expect(page).to have_css 'article[data-document-id="114189"]' end end context 'when searching by related title' do before do fill_in 'q', with: 'Bear Cove Head to Brigus South' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="24798226"]' + expect(page).to have_css 'article[data-document-id="24798226"]' end end end @@ -74,55 +74,55 @@ context 'when searching by person author (natural order)' do before do fill_in 'q', with: 'Michelle Obama' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="24053587"]' + expect(page).to have_css 'article[data-document-id="24053587"]' end end context 'when searching by person author (inverted order)' do before do fill_in 'q', with: 'Obama, Michelle' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="24053587"]' + expect(page).to have_css 'article[data-document-id="24053587"]' end end context 'when searching by corporate author' do before do fill_in 'q', with: 'Pennsylvania Institution for the Instruction of the Blind' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="79172"]' + expect(page).to have_css 'article[data-document-id="79172"]' end end context 'when searching by conference author' do before do fill_in 'q', with: 'IEEE International Frequency Control Symposium' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="1443986"]' + expect(page).to have_css 'article[data-document-id="1443986"]' end end context 'when searching by author (vernacular)' do before do fill_in 'q', with: '新聞局' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="6844545"]' + expect(page).to have_css 'article[data-document-id="6844545"]' end end end @@ -135,35 +135,35 @@ context 'when using a basic search' do before do fill_in 'q', with: 'geology' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="2680348"]' - expect(page).to have_selector 'article[data-document-id="2724728"]' + expect(page).to have_css 'article[data-document-id="2680348"]' + expect(page).to have_css 'article[data-document-id="2724728"]' end end context 'when using a fuller search without quotes' do before do fill_in 'q', with: 'African American women lawyers--Illinois--Chicago--Biography' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="24053587"]' + expect(page).to have_css 'article[data-document-id="24053587"]' end end context 'when using a fuller search with quotes' do before do fill_in 'q', with: '"African American women"' - click_button 'search' + click_on 'search' end it 'results include expected CAT keys' do - expect(page).to have_selector 'article[data-document-id="24053587"]' - expect(page).not_to have_selector 'article[data-document-id="22080733"]' + expect(page).to have_css 'article[data-document-id="24053587"]' + expect(page).to have_no_css 'article[data-document-id="22080733"]' end end end diff --git a/spec/features/book_covers_spec.rb b/spec/features/book_covers_spec.rb index 0c5fad28..ee7e2286 100644 --- a/spec/features/book_covers_spec.rb +++ b/spec/features/book_covers_spec.rb @@ -2,20 +2,20 @@ require 'rails_helper' -RSpec.describe 'BookCovers', type: :feature do +RSpec.describe 'BookCovers' do before do stub_request(:any, /hathitrust/).to_return(status: 200, body: '{}', headers: {}) end describe 'User searches for a book' do - it 'that happens to have a book cover in the Google Books API', js: true do + it 'that happens to have a book cover in the Google Books API', :js do visit '/?utf8=✓&search_field=all_fields&q=Ethical+and+Social+Issues+in+the+Information+Age+AND+9783319707129' expect(page).to have_css('img[src*="https://books.google.com/books/content"]') end end describe 'User opens a catalog record page' do - it 'that happens to have a book cover in the Google Books API', js: true do + it 'that happens to have a book cover in the Google Books API', :js do visit '/catalog/22090269' expect(page).to have_css('img[src*="https://books.google.com/books/content"]') end diff --git a/spec/features/bookmarks_spec.rb b/spec/features/bookmarks_spec.rb index 7922438a..7e78fbd0 100644 --- a/spec/features/bookmarks_spec.rb +++ b/spec/features/bookmarks_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Bookmarks', type: :feature, js: true do +RSpec.describe 'Bookmarks', :js do before do # In Rails 6, CSRF protection is turned off by default in test env # Turning it on here to test that it doesn't break Bookmarks @@ -36,11 +36,11 @@ it 'Adds, removes, re-adds bookmarks, and views Bookmarks page' do visit '/' # Test that the 'Bookmark All On Page' button doesn't show on empty search - expect(page).not_to have_content 'Bookmark All On Page' + expect(page).to have_no_content 'Bookmark All On Page' visit '/?search_field=all_fields&q=' expect(page).to have_content 'Bookmark All On Page' first_title = find_all('h3[class^="index_title"]').first.text - bookmark_all_button = find('#bookmark-all') + bookmark_all_button = find_by_id('bookmark-all') bookmark_buttons = find_all('.toggle-bookmark') bookmark_buttons.each do |button| expect(button.text).to eq 'Bookmark' @@ -69,7 +69,7 @@ expect(button.text).to eq 'In Bookmarks' end # Test that the Bookmarks page has proper content - click_link 'Bookmarks' + click_on 'Bookmarks' expect(page).to have_css :h1, text: 'Bookmarks' expect(page).to have_content '1 - 10 of 10' expect(page).to have_content first_title diff --git a/spec/features/browse/author_spec.rb b/spec/features/browse/author_spec.rb index 433f2ac6..0f12c9cb 100644 --- a/spec/features/browse/author_spec.rb +++ b/spec/features/browse/author_spec.rb @@ -2,12 +2,12 @@ require 'rails_helper' -RSpec.describe 'Author Browse', type: :feature do +RSpec.describe 'Author Browse' do context 'when starting at the beginning' do specify do visit author_browse_path - expect(page).to have_selector('h1', text: 'Browse by Author') + expect(page).to have_css('h1', text: 'Browse by Author') within('thead') do expect(page).to have_content('Author') @@ -16,24 +16,24 @@ within('tbody tr:nth-child(1)') do expect(page).to have_link('01 Distribution', href: /all_authors_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end within('tbody tr:nth-child(20)') do expect(page).to have_link('Akhtar, Adeel', href: /all_authors_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end first(:link, 'Next').click within('tbody tr:nth-child(1)') do expect(page).to have_link('Akin, Fatih, 1973-', href: /all_authors_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end within('tbody tr:nth-child(20)') do expect(page).to have_link('American Occupational Therapy Association', href: /all_authors_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end end end @@ -42,7 +42,7 @@ specify do visit author_browse_path(page: '3') - expect(page).to have_selector('h1', text: 'Browse by Author') + expect(page).to have_css('h1', text: 'Browse by Author') within('thead') do expect(page).to have_content('Author') @@ -51,24 +51,24 @@ within('tbody tr:nth-child(1)') do expect(page).to have_link('American Occupational Therapy Foundation', href: /all_authors_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end within('tbody tr:nth-child(20)') do expect(page).to have_link('Arthur, James R.', href: /all_authors_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end first(:link, 'Previous').click within('tbody tr:nth-child(1)') do expect(page).to have_link('Akin, Fatih, 1973-', href: /all_authors_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end within('tbody tr:nth-child(20)') do expect(page).to have_link('American Occupational Therapy Association', href: /all_authors_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end end end @@ -78,7 +78,7 @@ visit author_browse_path(prefix: 'glo') expect(page).to have_link('Global Film Initiative', href: /all_authors_facet/) - expect(page).not_to have_link('Steinem, Gloria', href: /all_authors_facet/) + expect(page).to have_no_link('Steinem, Gloria', href: /all_authors_facet/) end end end diff --git a/spec/features/browse/call_number_spec.rb b/spec/features/browse/call_number_spec.rb index 6beea828..78d90520 100644 --- a/spec/features/browse/call_number_spec.rb +++ b/spec/features/browse/call_number_spec.rb @@ -2,24 +2,24 @@ require 'rails_helper' -RSpec.describe 'Call Number Browse', type: :feature do +RSpec.describe 'Call Number Browse' do context 'when Browse by LC Call Numbers' do context 'when the user is not searching for a particular call number' do specify do visit '/browse/call_numbers?classification=lc' - expect(page).to have_selector 'h2.h4', - exact_text: 'AP3.M33 to BM516.B5134 1948' + expect(page).to have_css 'h2.h4', + exact_text: 'AP3.M33 to BM516.B5134 1948' - expect(page).not_to have_selector '.table-primary' + expect(page).to have_no_css '.table-primary' expect(page).to have_link('AP2.O354', href: '/catalog/107') - expect(page).to have_selector 'tr:nth-child(4) td:nth-child(2)', - exact_text: 'The Christmas locket' - expect(page).to have_selector 'tr:nth-child(4) td:nth-child(3)', - exact_text: 'Special Collections Library' - expect(page).to have_selector 'tr:nth-child(4) td:nth-child(4)', - exact_text: 'Boston : Roberts brothers, 1870-' + expect(page).to have_css 'tr:nth-child(4) td:nth-child(2)', + exact_text: 'The Christmas locket' + expect(page).to have_css 'tr:nth-child(4) td:nth-child(3)', + exact_text: 'Special Collections Library' + expect(page).to have_css 'tr:nth-child(4) td:nth-child(4)', + exact_text: 'Boston : Roberts brothers, 1870-' end end @@ -28,20 +28,20 @@ specify do visit '/browse/call_numbers?nearby=F127.A2M9 1869&classification=lc' - expect(page).to have_selector 'h2.h4', - exact_text: 'E909.O24A3 2018 to HB179.T84' + expect(page).to have_css 'h2.h4', + exact_text: 'E909.O24A3 2018 to HB179.T84' expect(page).to have_link('F127.A2M9 1869', href: '/catalog/213578') - expect(page).to have_selector 'tr.table-primary:nth-child(2) td:nth-child(2)', - exact_text: 'Adventures in the wilderness, or, Camp life in ' \ - 'the Adirondacks / By William H.H. Murray ...' + expect(page).to have_css 'tr.table-primary:nth-child(2) td:nth-child(2)', + exact_text: 'Adventures in the wilderness, or, Camp life in ' \ + 'the Adirondacks / By William H.H. Murray ...' - expect(page).to have_selector 'tr.table-primary:nth-child(2) td:nth-child(3)', - exact_text: 'Annex / Special Collections Library' + expect(page).to have_css 'tr.table-primary:nth-child(2) td:nth-child(3)', + exact_text: 'Annex / Special Collections Library' - expect(page).to have_selector 'tr.table-primary:nth-child(2) td:nth-child(4)', - exact_text: 'Boston : Fields, Osgood & co., 1869.' + expect(page).to have_css 'tr.table-primary:nth-child(2) td:nth-child(4)', + exact_text: 'Boston : Fields, Osgood & co., 1869.' end end @@ -49,11 +49,11 @@ specify do visit '/browse/call_numbers?nearby=LOL&classification=lc' - expect(page).to have_selector 'h2.h4', - exact_text: 'LC1421.M83 1801 v.1-2 to M1600.H133B45 1998 CD' + expect(page).to have_css 'h2.h4', + exact_text: 'LC1421.M83 1801 v.1-2 to M1600.H133B45 1998 CD' - expect(page).to have_selector 'tr.table-primary:nth-child(2) td', - exact_text: 'You\'re looking for: LOL' + expect(page).to have_css 'tr.table-primary:nth-child(2) td', + exact_text: 'You\'re looking for: LOL' end end end @@ -64,18 +64,18 @@ specify do visit '/browse/call_numbers?classification=dewey' - expect(page).to have_selector 'h2.h4', - exact_text: '001B289h to 590.52An7' + expect(page).to have_css 'h2.h4', + exact_text: '001B289h to 590.52An7' - expect(page).not_to have_selector '.table-primary' + expect(page).to have_no_css '.table-primary' expect(page).to have_link('001B289h', href: '/catalog/839980') - expect(page).to have_selector 'tr:nth-child(2) td:nth-child(2)', - exact_text: 'An international bibliography on atomic energy' - expect(page).to have_selector 'tr:nth-child(2) td:nth-child(3)', - exact_text: 'Annex' - expect(page).to have_selector 'tr:nth-child(2) td:nth-child(4)', - exact_text: 'Lake Success : [publisher not identified], 1949-1951.' + expect(page).to have_css 'tr:nth-child(2) td:nth-child(2)', + exact_text: 'An international bibliography on atomic energy' + expect(page).to have_css 'tr:nth-child(2) td:nth-child(3)', + exact_text: 'Annex' + expect(page).to have_css 'tr:nth-child(2) td:nth-child(4)', + exact_text: 'Lake Success : [publisher not identified], 1949-1951.' end end @@ -84,19 +84,19 @@ specify do visit '/browse/call_numbers?nearby=301.154G854c&classification=dewey' - expect(page).to have_selector 'h2.h4', - exact_text: '294.516B14b Zs to 977.3Il6c v.11' + expect(page).to have_css 'h2.h4', + exact_text: '294.516B14b Zs to 977.3Il6c v.11' expect(page).to have_link('301.154G854c', href: '/catalog/1373276') - expect(page).to have_selector 'tr.table-primary:nth-child(2) td:nth-child(2)', - exact_text: 'Children and politics / by Fred I. Greenstein' + expect(page).to have_css 'tr.table-primary:nth-child(2) td:nth-child(2)', + exact_text: 'Children and politics / by Fred I. Greenstein' - expect(page).to have_selector 'tr.table-primary:nth-child(2) td:nth-child(3)', - exact_text: 'Annex / Penn State Behrend / Penn State Harrisburg' + expect(page).to have_css 'tr.table-primary:nth-child(2) td:nth-child(3)', + exact_text: 'Annex / Penn State Behrend / Penn State Harrisburg' - expect(page).to have_selector 'tr.table-primary:nth-child(2) td:nth-child(4)', - exact_text: 'New Haven : Yale University Press, 1965.' + expect(page).to have_css 'tr.table-primary:nth-child(2) td:nth-child(4)', + exact_text: 'New Haven : Yale University Press, 1965.' end end @@ -105,11 +105,11 @@ pending('needs to be fixed') visit '/browse/call_numbers?nearby=LOL&classification=dewey' - expect(page).to have_selector 'h2.h4', - exact_text: 'None to None' + expect(page).to have_css 'h2.h4', + exact_text: 'None to None' - expect(page).to have_selector 'tr.table-primary:nth-child(2) td', - exact_text: 'You\'re looking for: LOL' + expect(page).to have_css 'tr.table-primary:nth-child(2) td', + exact_text: 'You\'re looking for: LOL' end end end diff --git a/spec/features/browse/subject_spec.rb b/spec/features/browse/subject_spec.rb index b930d77a..0e16af47 100644 --- a/spec/features/browse/subject_spec.rb +++ b/spec/features/browse/subject_spec.rb @@ -2,12 +2,12 @@ require 'rails_helper' -RSpec.describe 'Subject Browse', type: :feature do +RSpec.describe 'Subject Browse' do context 'when starting at the beginning' do specify do visit subject_browse_path - expect(page).to have_selector('h1', text: 'Browse by Subject') + expect(page).to have_css('h1', text: 'Browse by Subject') within('thead') do expect(page).to have_content('Subject Heading') @@ -16,24 +16,24 @@ within('tbody tr:nth-child(1)') do expect(page).to have_link('Adirondack Mountains (N.Y.)', href: /subject_browse_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end within('tbody tr:nth-child(20)') do expect(page).to have_link('Animals—Treatment—Fiction', href: /subject_browse_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end first(:link, 'Next').click within('tbody tr:nth-child(1)') do expect(page).to have_link('Aptheker, Herbert, 1915-2003', href: /subject_browse_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end within('tbody tr:nth-child(20)') do expect(page).to have_link('Authors, Yiddish—Soviet Union', href: /subject_browse_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end end end @@ -42,7 +42,7 @@ specify do visit subject_browse_path(page: '3') - expect(page).to have_selector('h1', text: 'Browse by Subject') + expect(page).to have_css('h1', text: 'Browse by Subject') within('thead') do expect(page).to have_content('Subject Heading') @@ -51,24 +51,24 @@ within('tbody tr:nth-child(1)') do expect(page).to have_link('Authors—Drama', href: /subject_browse_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end within('tbody tr:nth-child(20)') do expect(page).to have_link('Biometry', href: /subject_browse_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end first(:link, 'Previous').click within('tbody tr:nth-child(1)') do expect(page).to have_link('Aptheker, Herbert, 1915-2003', href: /subject_browse_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end within('tbody tr:nth-child(20)') do expect(page).to have_link('Authors, Yiddish—Soviet Union', href: /subject_browse_facet/) - expect(page).to have_selector('td', text: 1) + expect(page).to have_css('td', text: 1) end end end @@ -77,12 +77,12 @@ specify do visit subject_browse_path(prefix: 'Q') - expect(page).to have_selector('td', text: /^Quilting—Pennsylvania—Cumberland County—History—18th century$/) - expect(page).to have_selector('td', text: /^Quilting—Pennsylvania—Cumberland County—History—19th century$/) - expect(page).not_to have_selector('td', text: /^Quilting—Pennsylvania—Cumberland County—History$/) - expect(page).not_to have_selector('td', text: /^Quilting—Pennsylvania—Cumberland County$/) - expect(page).not_to have_selector('td', text: /^Quilting—Pennsylvania$/) - expect(page).not_to have_selector('td', text: /^Quilting$/) + expect(page).to have_css('td', text: /^Quilting—Pennsylvania—Cumberland County—History—18th century$/) + expect(page).to have_css('td', text: /^Quilting—Pennsylvania—Cumberland County—History—19th century$/) + expect(page).to have_no_css('td', text: /^Quilting—Pennsylvania—Cumberland County—History$/) + expect(page).to have_no_css('td', text: /^Quilting—Pennsylvania—Cumberland County$/) + expect(page).to have_no_css('td', text: /^Quilting—Pennsylvania$/) + expect(page).to have_no_css('td', text: /^Quilting$/) end end diff --git a/spec/features/browse/titles_spec.rb b/spec/features/browse/titles_spec.rb index c770fb0f..179a1d0b 100644 --- a/spec/features/browse/titles_spec.rb +++ b/spec/features/browse/titles_spec.rb @@ -2,25 +2,25 @@ require 'rails_helper' -RSpec.describe 'Title Browse', type: :feature do +RSpec.describe 'Title Browse' do context 'when the user is not searching for a particular title' do specify do visit '/browse/titles?prefix=' - expect(page).to have_selector('h1', text: 'Browse by Title') + expect(page).to have_css('h1', text: 'Browse by Title') within('thead') do expect(page).to have_content('Title') expect(page).to have_content('Count') end - expect(page).to have_selector 'tr:nth-child(3) td:nth-child(1)', - exact_text: '12th-century chant Abelard, hymns & sequences for Heloise' + expect(page).to have_css 'tr:nth-child(3) td:nth-child(1)', + exact_text: '12th-century chant Abelard, hymns & sequences for Heloise' first(:link, 'Next').click - expect(page).to have_selector 'tr:nth-child(2) td:nth-child(1)', - exact_text: 'American anthem' + expect(page).to have_css 'tr:nth-child(2) td:nth-child(1)', + exact_text: 'American anthem' end end @@ -37,20 +37,20 @@ specify do visit '/browse/titles?prefix=Becoming' - expect(page).to have_selector 'tr:nth-child(1) td:nth-child(1)', - exact_text: 'Becoming' - expect(page).to have_selector 'tr:nth-child(2) td:nth-child(1)', - exact_text: 'Becoming a champion the complete guide to the full swing' + expect(page).to have_css 'tr:nth-child(1) td:nth-child(1)', + exact_text: 'Becoming' + expect(page).to have_css 'tr:nth-child(2) td:nth-child(1)', + exact_text: 'Becoming a champion the complete guide to the full swing' end end context 'when the user selects a specific title' do specify do visit '/browse/titles?prefix=Becoming' - click_link 'Becoming' + click_on 'Becoming' - expect(page).to have_selector 'article[data-document-id="24053587"]' - expect(page).not_to have_selector 'article[data-document-id="3626147"]' + expect(page).to have_css 'article[data-document-id="24053587"]' + expect(page).to have_no_css 'article[data-document-id="3626147"]' end end end diff --git a/spec/features/campus_facet_all_online_spec.rb b/spec/features/campus_facet_all_online_spec.rb index 706348dd..9e98628f 100644 --- a/spec/features/campus_facet_all_online_spec.rb +++ b/spec/features/campus_facet_all_online_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' -RSpec.describe 'Campus Facet Add All Online', type: :feature do - describe 'Adding and removing online items to campus facet filter', js: true do +RSpec.describe 'Campus Facet Add All Online' do + describe 'Adding and removing online items to campus facet filter', :js do it 'adds online items' do # This test is dependent on there being 21 Behrend items and 134 # Online items. Adding records to the fixtures could break this. diff --git a/spec/features/cjk_search_spec.rb b/spec/features/cjk_search_spec.rb index 52999d69..7b209fcd 100644 --- a/spec/features/cjk_search_spec.rb +++ b/spec/features/cjk_search_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Chinese, Japanese, Korean searches', type: :feature do +RSpec.describe 'Chinese, Japanese, Korean searches' do it 'returns the same result for interchangeable traditional and simplified chinese searches' do # Traditional: 中國文學史 | Simplified: 中国文学史 visit "/?search_field=all_fields&q=#{CGI.escape('中國文學史')}" diff --git a/spec/features/external_links_spec.rb b/spec/features/external_links_spec.rb index 877f9b48..b452eca0 100644 --- a/spec/features/external_links_spec.rb +++ b/spec/features/external_links_spec.rb @@ -2,12 +2,12 @@ require 'rails_helper' -RSpec.describe 'External Links', type: :feature do +RSpec.describe 'External Links' do context 'when user searches for a record' do context 'when record has no external links' do it 'does not display any links' do visit 'catalog/26513585' - expect(page).not_to have_selector '.external_links' + expect(page).to have_no_css '.external_links' end end @@ -17,7 +17,7 @@ end it 'does not displays a toggle button' do - expect(page).not_to have_selector '.toggle-external-links' + expect(page).to have_no_css '.toggle-external-links' end it 'displays at least 2 links as preview' do @@ -32,7 +32,7 @@ end it 'displays a toggle button' do - expect(page).to have_selector '.toggle-external-links' + expect(page).to have_css '.toggle-external-links' end it 'displays 2 links as preview' do @@ -40,7 +40,7 @@ .and have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-2-eng.pdf') end - it 'toggles links correctly', js: true do + it 'toggles links correctly', :js do click_link_or_button('collapseLinksAccessOnlineBtn') expect(page).to have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-1-eng.pdf') .and have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-2-eng.pdf') @@ -49,12 +49,12 @@ click_link_or_button('collapseLinksAccessOnlineBtn') expect(page).to have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-1-eng.pdf') .and have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-2-eng.pdf') - expect(page).not_to have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-3-eng.pdf') - expect(page).not_to have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-4-eng.pdf') + expect(page).to have_no_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-3-eng.pdf') + expect(page).to have_no_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-4-eng.pdf') end end - context 'when record has links of the different types', js: true do + context 'when record has links of the different types', :js do it 'toggles links correctly' end end @@ -63,7 +63,7 @@ context 'when record has less than 3 links of the same type' do it 'does not display any external links' do visit '?search_field=all_fields&q=40+short+stories' - expect(page).not_to have_selector '.external_links' + expect(page).to have_no_css '.external_links' end end @@ -73,7 +73,7 @@ end it 'does not displays a toggle button' do - expect(page).not_to have_selector '.toggle-external-links' end + expect(page).to have_no_css '.toggle-external-links' end it 'displays at least 2 links as preview' do expect(page).to have_link('journals.openedition.org', @@ -87,7 +87,7 @@ end it 'displays a toggle button' do - expect(page).to have_selector '.toggle-external-links' + expect(page).to have_css '.toggle-external-links' end it 'displays 2 links as preview' do @@ -95,7 +95,7 @@ .and have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-2-eng.pdf') end - it 'toggles links correctly', js: true do + it 'toggles links correctly', :js do click_link_or_button('collapseLinksAccessOnlineBtn') expect(page).to have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-1-eng.pdf') .and have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-2-eng.pdf') @@ -104,12 +104,12 @@ click_link_or_button('collapseLinksAccessOnlineBtn') expect(page).to have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-1-eng.pdf') .and have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-2-eng.pdf') - expect(page).not_to have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-3-eng.pdf') - expect(page).not_to have_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-4-eng.pdf') + expect(page).to have_no_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-3-eng.pdf') + expect(page).to have_no_link('publications.gc.ca', href: 'http://publications.gc.ca/collections/collection_2016/rncan-nrcan/M183-2-6450-4-eng.pdf') end end - context 'when record has links of the different types', js: true do + context 'when record has links of the different types', :js do it 'toggles links correctly' end end diff --git a/spec/features/facet_queries_spec.rb b/spec/features/facet_queries_spec.rb index d875af43..eb6f70d1 100644 --- a/spec/features/facet_queries_spec.rb +++ b/spec/features/facet_queries_spec.rb @@ -2,31 +2,31 @@ require 'rails_helper' -RSpec.describe 'Facet Queries', type: :feature do +RSpec.describe 'Facet Queries' do it 'All Authors Facet' do visit '/?f%5Ball_authors_facet%5D%5B%5D=Chanukoff%2C+L.%2C+1892-1958' - expect(page).to have_selector '.filter-name', - exact_text: 'All Authors Facet' - expect(page).to have_selector '.filter-value', - exact_text: 'Chanukoff, L., 1892-1958' - expect(page).to have_selector 'article[data-document-id="3750004"]' + expect(page).to have_css '.filter-name', + exact_text: 'All Authors Facet' + expect(page).to have_css '.filter-value', + exact_text: 'Chanukoff, L., 1892-1958' + expect(page).to have_css 'article[data-document-id="3750004"]' end it 'Subject Facet' do visit '/?f[subject_facet][]=Islamic+decorative+arts%E2%80%94Turkey' - expect(page).to have_selector '.filter-name', - exact_text: 'Subject Facet' - expect(page).to have_selector '.filter-value', - exact_text: 'Islamic decorative arts—Turkey' - expect(page).to have_selector 'article[data-document-id="21322677"]' + expect(page).to have_css '.filter-name', + exact_text: 'Subject Facet' + expect(page).to have_css '.filter-value', + exact_text: 'Islamic decorative arts—Turkey' + expect(page).to have_css 'article[data-document-id="21322677"]' end it 'Title Facet' do visit '/?f%5Btitle_sort%5D%5B%5D=Becoming' - expect(page).to have_selector '.filter-name', - exact_text: 'Title' - expect(page).to have_selector '.filter-value', - exact_text: 'Becoming' - expect(page).to have_selector 'article[data-document-id="24053587"]' + expect(page).to have_css '.filter-name', + exact_text: 'Title' + expect(page).to have_css '.filter-value', + exact_text: 'Becoming' + expect(page).to have_css 'article[data-document-id="24053587"]' end end diff --git a/spec/features/google_preview_link_spec.rb b/spec/features/google_preview_link_spec.rb index 17fac7d6..bf706362 100644 --- a/spec/features/google_preview_link_spec.rb +++ b/spec/features/google_preview_link_spec.rb @@ -3,7 +3,7 @@ require 'rails_helper' require 'support/vcr' -RSpec.describe 'Google Preview Link', :vcr, type: :feature, js: true do +RSpec.describe 'Google Preview Link', :js, :vcr do before do allow_any_instance_of(ExternalLinks::GooglePreviewLinkComponent).to receive(:search_item).and_return 'LCCN:12345' end diff --git a/spec/features/header_navbar_spec.rb b/spec/features/header_navbar_spec.rb index 57b3b461..69fbd21f 100644 --- a/spec/features/header_navbar_spec.rb +++ b/spec/features/header_navbar_spec.rb @@ -2,14 +2,14 @@ require 'rails_helper' -RSpec.describe 'Header Navbar', type: :feature do +RSpec.describe 'Header Navbar' do it 'displays search bar except on Advanced Search' do visit root_path - expect(page).to have_selector '.navbar-search' + expect(page).to have_css '.navbar-search' end it 'does not display search bar on Advanced Search' do visit '/advanced' - expect(page).not_to have_selector '.navbar-search' + expect(page).to have_no_css '.navbar-search' end end diff --git a/spec/features/iiif_viewer_spec.rb b/spec/features/iiif_viewer_spec.rb index 8d0f66e3..1a185595 100644 --- a/spec/features/iiif_viewer_spec.rb +++ b/spec/features/iiif_viewer_spec.rb @@ -3,28 +3,28 @@ require 'rails_helper' require 'support/vcr' -RSpec.describe 'viewing a record', js: true, vcr: { record: :new_episodes } do +RSpec.describe 'viewing a record', :js, vcr: { record: :new_episodes } do context 'when the record does not have an IIIF manifest URL' do it 'does not render the Mirador viewer' do visit '/catalog/3500414' - expect(page).not_to have_selector 'div[id="iiif-viewer"]' + expect(page).to have_no_css 'div[id="iiif-viewer"]' end end context 'when the record has an IIIF manifest URL' do it 'renders the Mirador viewer with no workspace type' do visit '/catalog/2025781' - expect(page).to have_selector 'div[id="iiif-viewer"]' - expect(page).to have_selector 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' - expect(page).not_to have_selector 'div[class="mosaic-window-body"]' + expect(page).to have_css 'div[id="iiif-viewer"]' + expect(page).to have_css 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' + expect(page).to have_no_css 'div[class="mosaic-window-body"]' within '#iiif-viewer' do - expect(page).not_to have_content 'error' + expect(page).to have_no_content 'error' end end it 'does not show a link to the IIIF manifest file' do visit '/catalog/2025781' - expect(page).not_to have_link 'IIIF manifest' + expect(page).to have_no_link 'IIIF manifest' end end @@ -37,11 +37,11 @@ it 'renders the Mirador viewer with a mosaic workspace' do visit '/catalog/7280921' - expect(page).to have_selector 'div[id="iiif-viewer"]' - expect(page).to have_selector 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' - expect(page).to have_selector 'div[class="mosaic-window-body"]' + expect(page).to have_css 'div[id="iiif-viewer"]' + expect(page).to have_css 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' + expect(page).to have_css 'div[class="mosaic-window-body"]' within '#iiif-viewer' do - expect(page).not_to have_content 'error' + expect(page).to have_no_content 'error' end end end @@ -49,10 +49,10 @@ context 'when the record has an ARK URL that redirects to the IIIF manifest' do it 'renders the Mirador viewer' do visit '/catalog/1267921' - expect(page).to have_selector 'div[id="iiif-viewer"]' - expect(page).to have_selector 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' + expect(page).to have_css 'div[id="iiif-viewer"]' + expect(page).to have_css 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' within '#iiif-viewer' do - expect(page).not_to have_content 'error' + expect(page).to have_no_content 'error' end end end @@ -68,8 +68,8 @@ it 'renders the Mirador viewer' do visit '/catalog/1267921' - expect(page).to have_selector 'div[id="iiif-viewer"]' - expect(page).to have_selector 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' + expect(page).to have_css 'div[id="iiif-viewer"]' + expect(page).to have_css 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' end end @@ -82,8 +82,8 @@ it 'renders the Mirador viewer' do visit '/catalog/1267921' - expect(page).to have_selector 'div[id="iiif-viewer"]' - expect(page).to have_selector 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' + expect(page).to have_css 'div[id="iiif-viewer"]' + expect(page).to have_css 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' end end @@ -96,8 +96,8 @@ it 'renders the Mirador viewer' do visit '/catalog/1267921' - expect(page).to have_selector 'div[id="iiif-viewer"]' - expect(page).to have_selector 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' + expect(page).to have_css 'div[id="iiif-viewer"]' + expect(page).to have_css 'main[class="Connect(WithPlugins(WorkspaceArea))-viewer-1 mirador-viewer"]' end end end diff --git a/spec/features/marc_view_spec.rb b/spec/features/marc_view_spec.rb index df18b548..c033e2c4 100644 --- a/spec/features/marc_view_spec.rb +++ b/spec/features/marc_view_spec.rb @@ -2,15 +2,15 @@ require 'rails_helper' -RSpec.describe 'MARC view', type: :feature do - describe 'MARC view', js: true do +RSpec.describe 'MARC view' do + describe 'MARC view', :js do before do visit '/catalog/24053587' end it 'single item page contains link to MARC record' do - expect(page).to have_selector 'a[id="marc_record_link"]' - expect(page).to have_selector 'a[href="/catalog/24053587/marc_view"]' + expect(page).to have_css 'a[id="marc_record_link"]' + expect(page).to have_css 'a[href="/catalog/24053587/marc_view"]' end context 'when MARC link is clicked' do diff --git a/spec/features/prev_next_spec.rb b/spec/features/prev_next_spec.rb index eafeb03d..db20a9cf 100644 --- a/spec/features/prev_next_spec.rb +++ b/spec/features/prev_next_spec.rb @@ -2,18 +2,18 @@ require 'rails_helper' -RSpec.describe 'Previous Next Toggle', type: :feature do - describe 'Previous next links toggle', js: true do +RSpec.describe 'Previous Next Toggle' do + describe 'Previous next links toggle', :js do it 'does not display stale previous and next links for direct item views' do visit root_path fill_in 'q', with: '' - click_button 'search' + click_on 'search' click_on 'An American marriage / a novel by Tayari Jones' expect(page.text).to match(/← Previous | [0-9]+ of [0-9]+ | Next →/) # Go to the number 6 result separately visit '/catalog/24053587' - expect(page).not_to have_selector '.page-links' + expect(page).to have_no_css '.page-links' expect(page.text).not_to match(/← Previous | [0-9]+ of [0-9]+ | Next →/) end end diff --git a/spec/features/search_bar_spec.rb b/spec/features/search_bar_spec.rb index 3bd0c62e..9d1e1c1e 100644 --- a/spec/features/search_bar_spec.rb +++ b/spec/features/search_bar_spec.rb @@ -2,68 +2,74 @@ require 'rails_helper' -RSpec.describe 'Search Bar', type: :feature do - describe 'selected search box field', js: true do +RSpec.describe 'Search Bar' do + describe 'selected search box field', :js do it 'shows normal placeholder info when doing a keyword search' do visit '/?search_field=all_fields&q=' expect(page).to have_select('search_field', selected: 'Keyword') - expect(page).to have_selector('#q[placeholder="Search..."]') + expect(page).to have_css('#q[placeholder="Search..."]') end it 'shows lc call number browse info when browsing by call number' do visit '/browse/call_numbers?nearby=LOL&classification=lc' expect(page).to have_select('search_field', selected: 'Browse by LC Call Number') - expect(page).to have_selector('#q[placeholder="e.g. NK 9112 .A28"]') + expect(page).to have_css('#q[placeholder="e.g. NK 9112 .A28"]') end it 'shows dewey call number browse info when browsing by call number' do visit '/browse/call_numbers?nearby=LOL&classification=dewey' expect(page).to have_select('search_field', selected: 'Browse by Dewey Call Number') - expect(page).to have_selector('#q[placeholder="e.g. 332.094K634f"]') + expect(page).to have_css('#q[placeholder="e.g. 332.094K634f"]') end it 'shows author browse info when browsing by author' do visit '/browse/authors?prefix=A' expect(page).to have_select('search_field', selected: 'Browse by Author') - expect(page).to have_selector('#q[placeholder="e.g. Hurston, Zora"]') + expect(page).to have_css('#q[placeholder="e.g. Hurston, Zora"]') end it 'shows subject browse info when browsing by subject' do visit '/browse/subjects?prefix=S' expect(page).to have_select('search_field', selected: 'Browse by Subject') - expect(page).to have_selector('#q[placeholder="e.g. Microbiology"]') + expect(page).to have_css('#q[placeholder="e.g. Microbiology"]') end it 'shows title browse info when browsing by title' do visit '/browse/titles?prefix=T' expect(page).to have_select('search_field', selected: 'Browse by Title') - expect(page).to have_selector('#q[placeholder="Search..."]') + expect(page).to have_css('#q[placeholder="Search..."]') end end - it 'updates the placeholder when the search type changes', js: true do + it 'shows links for Advanced Search and Start Over', :js do + visit '/' + expect(page).to have_link('Advanced search', href: '/advanced') + expect(page).to have_link('Start Over', href: '/') + end + + it 'updates the placeholder when the search type changes', :js do visit '/' - expect(page).to have_selector('#q[placeholder="Search..."]') + expect(page).to have_css('#q[placeholder="Search..."]') select 'Browse by LC Call Number', from: 'search_field' expect(page).to have_select('search_field', selected: 'Browse by LC Call Number') - expect(page).to have_selector('#q[placeholder="e.g. NK 9112 .A28"]') + expect(page).to have_css('#q[placeholder="e.g. NK 9112 .A28"]') select 'Browse by Dewey Call Number', from: 'search_field' expect(page).to have_select('search_field', selected: 'Browse by Dewey Call Number') - expect(page).to have_selector('#q[placeholder="e.g. 332.094K634f"]') + expect(page).to have_css('#q[placeholder="e.g. 332.094K634f"]') select 'Browse by Author', from: 'search_field' expect(page).to have_select('search_field', selected: 'Browse by Author') - expect(page).to have_selector('#q[placeholder="e.g. Hurston, Zora"]') + expect(page).to have_css('#q[placeholder="e.g. Hurston, Zora"]') select 'Browse by Subject', from: 'search_field' expect(page).to have_select('search_field', selected: 'Browse by Subject') - expect(page).to have_selector('#q[placeholder="e.g. Microbiology"]') + expect(page).to have_css('#q[placeholder="e.g. Microbiology"]') select 'Browse by Title', from: 'search_field' expect(page).to have_select('search_field', selected: 'Browse by Title') - expect(page).to have_selector('#q[placeholder="Search..."]') + expect(page).to have_css('#q[placeholder="Search..."]') end end diff --git a/spec/features/search_results_spec.rb b/spec/features/search_results_spec.rb index 2e5b78de..d58311a8 100644 --- a/spec/features/search_results_spec.rb +++ b/spec/features/search_results_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' -RSpec.describe 'Search Results', type: :feature do - describe 'search result page', js: true do +RSpec.describe 'Search Results' do + describe 'search result page', :js do before do visit '/?search_field=all_fields&q=history' end @@ -23,8 +23,8 @@ context 'when there are results to display' do it 'displays results content' do within '#documents' do - expect(page).to have_selector 'article[data-document-id="124958"]' - expect(page).not_to have_content 'No results found for your search' + expect(page).to have_css 'article[data-document-id="124958"]' + expect(page).to have_no_content 'No results found for your search' end end end @@ -41,7 +41,7 @@ expect(page).to have_link 'Libraries worldwide (WorldCat)' expect(page).to have_link 'Public domain books and journals: HathiTrust' expect(page).to have_link 'Articles: Google Scholar' - expect(page).not_to have_selector 'article[data-document-id="124958"]' + expect(page).to have_no_css 'article[data-document-id="124958"]' end end end diff --git a/spec/features/share_spec.rb b/spec/features/share_spec.rb index 65d89ac9..d33e4f61 100644 --- a/spec/features/share_spec.rb +++ b/spec/features/share_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe "Using the 'Share' dropdown", type: :feature do +RSpec.describe "Using the 'Share' dropdown" do let(:expected_content_type) { 'application/x-research-info-systems' } let(:expected_file_name) { 'document.ris' } diff --git a/spec/features/single_item_browse_button_spec.rb b/spec/features/single_item_browse_button_spec.rb index 02e84210..df11523d 100644 --- a/spec/features/single_item_browse_button_spec.rb +++ b/spec/features/single_item_browse_button_spec.rb @@ -2,26 +2,26 @@ require 'rails_helper' -RSpec.describe 'Single Item Browse Button', type: :feature do - context 'when record has one LC call number', js: true do +RSpec.describe 'Single Item Browse Button' do + context 'when record has one LC call number', :js do before do visit '/catalog/22080733' end it 'displays browse button for LC call number' do - expect(page).not_to have_selector('button[data-toggle=dropdown]') + expect(page).to have_no_css('button[data-toggle=dropdown]') expect(page).to have_link('Browse Nearby on Shelf', href: '/browse/call_numbers?classification=lc&nearby=PS3610.O63A84+2018') end end - context 'when record has multiple LC call numbers', js: true do + context 'when record has multiple LC call numbers', :js do before do visit '/catalog/53953' end it 'displays browse button for LC call numbers' do - expect(page).to have_selector('button[data-toggle=dropdown]') + expect(page).to have_css('button[data-toggle=dropdown]') expect(page).to have_link('AP3.M33', href: '/browse/call_numbers?classification=lc&nearby=AP3.M33', visible: :hidden) @@ -31,25 +31,25 @@ end end - context 'when record has one Dewey call number', js: true do + context 'when record has one Dewey call number', :js do before do visit '/catalog/1043229' end it 'displays browse button for Dewey call number' do - expect(page).not_to have_selector('button[data-toggle=dropdown]') + expect(page).to have_no_css('button[data-toggle=dropdown]') expect(page).to have_link('Browse Nearby on Shelf', href: '/browse/call_numbers?classification=dewey&nearby=111.85M35b') end end - context 'when record has multiple Dewey call numbers', js: true do + context 'when record has multiple Dewey call numbers', :js do before do visit '/catalog/307724' end it 'displays browse button for Dewey call numbers' do - expect(page).to have_selector('button[data-toggle=dropdown]') + expect(page).to have_css('button[data-toggle=dropdown]') expect(page).to have_link('016.53976Un3i', href: '/browse/call_numbers?classification=dewey&nearby=016.53976Un3i', visible: :hidden) @@ -59,13 +59,13 @@ end end - context 'when record has multiple LC and Dewey call numbers', js: true do + context 'when record has multiple LC and Dewey call numbers', :js do before do visit '/catalog/423287' end it 'displays browse button for LC call numbers' do - expect(page).to have_selector('button[data-toggle=dropdown]') + expect(page).to have_css('button[data-toggle=dropdown]') expect(page).to have_link('HQ1061.M5 Selections', href: '/browse/call_numbers?classification=lc&nearby=HQ1061.M5+Selections', visible: :hidden) diff --git a/spec/features/single_item_genre_spec.rb b/spec/features/single_item_genre_spec.rb index e5aacea8..1f2d0d04 100644 --- a/spec/features/single_item_genre_spec.rb +++ b/spec/features/single_item_genre_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' -RSpec.describe 'Single Item Genre', type: :feature do - describe 'Single item genre links', js: true do +RSpec.describe 'Single Item Genre' do + describe 'Single item genre links', :js do before do visit '/catalog/22080733' end @@ -12,14 +12,14 @@ within 'dd.blacklight-genre_display_ssm.ml-5' do expect(page).to have_content 'Domestic fiction' expect(page).to have_content 'Fiction' - expect(page).not_to have_content 'FICTION / Women' + expect(page).to have_no_content 'FICTION / Women' end end it 'links to that genre' do click_on 'Domestic fiction' - expect(page).to have_selector 'article[data-document-id="22080733"]' - expect(page).to have_selector 'article[data-document-id="2052181"]' + expect(page).to have_css 'article[data-document-id="22080733"]' + expect(page).to have_css 'article[data-document-id="2052181"]' end end end diff --git a/spec/features/single_item_publication_fields_spec.rb b/spec/features/single_item_publication_fields_spec.rb index de8b2d0f..860e6207 100644 --- a/spec/features/single_item_publication_fields_spec.rb +++ b/spec/features/single_item_publication_fields_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' -RSpec.describe 'Single Item Publication Fields', type: :feature do - describe 'Single item publication fields', js: true do +RSpec.describe 'Single Item Publication Fields' do + describe 'Single item publication fields', :js do context 'when the item has multiple indicators for MARC field 264' do before do visit '/catalog/19437' @@ -37,7 +37,7 @@ end it 'does not display missing fields' do - expect(page).not_to have_content 'Copyright Date:' + expect(page).to have_no_content 'Copyright Date:' end end diff --git a/spec/features/single_item_subjects_spec.rb b/spec/features/single_item_subjects_spec.rb index 8796d815..b122e34d 100644 --- a/spec/features/single_item_subjects_spec.rb +++ b/spec/features/single_item_subjects_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' -RSpec.describe 'Single Item Subjects', type: :feature do - describe 'Single item subject links', js: true do +RSpec.describe 'Single Item Subjects' do + describe 'Single item subject links', :js do before do visit '/catalog/1839879' end @@ -20,8 +20,8 @@ end it 'takes them to a search result of the first term of a given subject' do - expect(page).to have_selector 'article[data-document-id="22080733"]' - expect(page).to have_selector 'article[data-document-id="1839879"]' + expect(page).to have_css 'article[data-document-id="22080733"]' + expect(page).to have_css 'article[data-document-id="1839879"]' end end @@ -31,8 +31,8 @@ end it 'takes them to a search result of the full term of a given subject' do - expect(page).to have_selector 'article[data-document-id="1839879"]' - expect(page).not_to have_selector 'article[data-document-id="22080733"]' + expect(page).to have_css 'article[data-document-id="1839879"]' + expect(page).to have_no_css 'article[data-document-id="22080733"]' end end end diff --git a/spec/features/sort_by_spec.rb b/spec/features/sort_by_spec.rb index 78718d7d..67c14ef1 100644 --- a/spec/features/sort_by_spec.rb +++ b/spec/features/sort_by_spec.rb @@ -2,8 +2,8 @@ require 'rails_helper' -RSpec.describe 'Sort by', type: :feature do - describe 'search result page', js: true do +RSpec.describe 'Sort by' do + describe 'search result page', :js do before do visit '/?search_field=all_fields&q=history' click_on 'Sort by relevance' @@ -20,7 +20,7 @@ it 'displays results content' do within '#documents' do - expect(page).to have_selector 'article[data-document-id="11160284"]' + expect(page).to have_css 'article[data-document-id="11160284"]' end end end @@ -36,7 +36,7 @@ it 'displays results content' do within '#documents' do - expect(page).to have_selector 'article[data-document-id="21601671"]' + expect(page).to have_css 'article[data-document-id="21601671"]' end end end @@ -52,7 +52,7 @@ it 'displays results content' do within '#documents' do - expect(page).to have_selector 'article[data-document-id="1293861"]' + expect(page).to have_css 'article[data-document-id="1293861"]' end end end @@ -68,8 +68,8 @@ it 'displays results content' do within '#documents' do - expect(page).to have_selector 'article[data-document-id="27422489"]' - expect(page).not_to have_selector 'article[data-document-id="11160284"]' + expect(page).to have_css 'article[data-document-id="27422489"]' + expect(page).to have_no_css 'article[data-document-id="11160284"]' end end end diff --git a/spec/helpers/catalog_helper_spec.rb b/spec/helpers/catalog_helper_spec.rb index 9d2ed6c5..2eb56f77 100644 --- a/spec/helpers/catalog_helper_spec.rb +++ b/spec/helpers/catalog_helper_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe CatalogHelper, type: :helper do +RSpec.describe CatalogHelper do describe '#bound_info' do let (:field_data) { ['{"bound_catkey": "355035", ' \ '"bound_title": "The high-caste Hindu woman / With introduction by Rachel L. Bodley",' \ @@ -134,7 +134,7 @@ additional_text: 'By blah blah blah.' }] }] }} it 'returns the first value of the value array' do - expect(get_first_only(options)).not_to be_a_kind_of Array + expect(get_first_only(options)).not_to be_a Array end end end diff --git a/spec/helpers/search_links_helper_spec.rb b/spec/helpers/search_links_helper_spec.rb index 05ee5b94..e934db4a 100644 --- a/spec/helpers/search_links_helper_spec.rb +++ b/spec/helpers/search_links_helper_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe SearchLinksHelper, type: :helper do +RSpec.describe SearchLinksHelper do describe '#other_subjectify' do let (:field_data) { ['Power Amplifiers', 'Research', diff --git a/spec/models/holdings_spec.rb b/spec/models/holdings_spec.rb index cacb94aa..91238298 100644 --- a/spec/models/holdings_spec.rb +++ b/spec/models/holdings_spec.rb @@ -42,7 +42,7 @@ expect(holdings.items.length).to eq(4) item = holdings.find('key_1') expect(item.call_number).to eq('Solr Doc 1') - expect(item.documents.map { |document| document['title_display_ssm'] }).to contain_exactly('Title 1') + expect(item.documents.pluck('title_display_ssm')).to contain_exactly('Title 1') end end @@ -83,7 +83,7 @@ expect(holdings.items.length).to eq(3) item = holdings.find('key_1') expect(item.call_number).to eq('Solr Doc 1') - expect(item.documents.map { |document| document['title_display_ssm'] }).to contain_exactly('Title 1', 'Title 2') + expect(item.documents.pluck('title_display_ssm')).to contain_exactly('Title 1', 'Title 2') end end diff --git a/spec/models/search_builder_spec.rb b/spec/models/search_builder_spec.rb index 613577a3..2ca83add 100644 --- a/spec/models/search_builder_spec.rb +++ b/spec/models/search_builder_spec.rb @@ -1,6 +1,6 @@ require 'rails_helper' -RSpec.describe SearchBuilder, type: :model do +RSpec.describe SearchBuilder do describe '#add_all_online_to_query' do let(:scope) do struct = Struct.new(:blacklight_config) diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb index 9746b462..d113dab0 100644 --- a/spec/rails_helper.rb +++ b/spec/rails_helper.rb @@ -52,7 +52,7 @@ RSpec.configure do |config| # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures - config.fixture_path = "#{::Rails.root}/spec/fixtures" + config.fixture_paths = [Rails.root.join('spec/fixtures').to_s] # If you're not using ActiveRecord, or you'd prefer not to run each of your # examples within a transaction, remove the following line or assign false diff --git a/spec/requests/catalog_spec.rb b/spec/requests/catalog_spec.rb index 823f1b61..70a92ea1 100644 --- a/spec/requests/catalog_spec.rb +++ b/spec/requests/catalog_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Catalog', type: :request do +RSpec.describe 'Catalog' do describe 'id in the url ending with a punctuation' do it 'redirects to the record after cleaning the punctuation' do get '/catalog/22090269.' diff --git a/spec/requests/errors_spec.rb b/spec/requests/errors_spec.rb index 71937914..7c4afaab 100644 --- a/spec/requests/errors_spec.rb +++ b/spec/requests/errors_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Errors', type: :request do +RSpec.describe 'Errors' do describe 'not found text' do before(:all) { get '/Copernicus.txt' } diff --git a/spec/routing/routing_spec.rb b/spec/routing/routing_spec.rb index a76ad3cb..5f280f43 100644 --- a/spec/routing/routing_spec.rb +++ b/spec/routing/routing_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'Error Routing', type: :routing do +RSpec.describe 'Error Routing' do it 'routes to page not found if path is completely invalid' do expect(get: 'kaljhgl').to route_to controller: 'errors', action: 'not_found', catch_unknown_routes: 'kaljhgl' end diff --git a/spec/services/document_ris_spec.rb b/spec/services/document_ris_spec.rb index dbc1a1ad..00e77c9f 100644 --- a/spec/services/document_ris_spec.rb +++ b/spec/services/document_ris_spec.rb @@ -4,12 +4,7 @@ RSpec.describe DocumentRis do let(:service) { described_class.new(document) } - let(:document) { [{ 'response' => - { 'numFound' => 1, - 'start' => 0, - 'numFoundExact' => true, - 'docs' => - [{ 'id' => '24053587', + let(:document) { { 'id' => '24053587', 'isbn_valid_ssm' => ['9781524763138', '1524763136'], 'title_245ab_tsim' => ['Becoming'], 'author_tsim' => ['Obama, Michelle, 1964-'], @@ -19,7 +14,7 @@ 'pub_date_illiad_ssm' => ['2018'], 'publisher_name_ssm' => ['Crown'], 'publication_place_ssm' => ['New York'], - 'format' => ['Book'] }] } }]} + 'format' => ['Book'] }} let(:ris) { "TY - BOOK\r\n" \ "TI - Becoming\r\n" \ "A1 - Obama, Michelle, 1964-\r\n" \ diff --git a/spec/services/shelf_query_spec.rb b/spec/services/shelf_query_spec.rb index 4109762d..c21818f5 100644 --- a/spec/services/shelf_query_spec.rb +++ b/spec/services/shelf_query_spec.rb @@ -17,7 +17,7 @@ context 'when the Solr configuration has only one shard' do # @note Technically, RSolr is returning RSolr::HashWithResponse but it's just a hash under the hood. let(:json_response) do - HashWithIndifferentAccess.new( + ActiveSupport::HashWithIndifferentAccess.new( { 'responseHeader' => { 'zkConnected' => true, @@ -63,7 +63,7 @@ context 'when the Solr configuration has more than one shard' do # @note Technically, RSolr is returning RSolr::HashWithResponse but it's just a hash under the hood. let(:json_response) do - HashWithIndifferentAccess.new( + ActiveSupport::HashWithIndifferentAccess.new( { 'responseHeader' => { 'zkConnected' => true, diff --git a/spec/views/advanced/_advanced_search_form.html.erb_spec.rb b/spec/views/advanced/_advanced_search_form.html.erb_spec.rb deleted file mode 100644 index 9aa7914b..00000000 --- a/spec/views/advanced/_advanced_search_form.html.erb_spec.rb +++ /dev/null @@ -1,21 +0,0 @@ -# frozen_string_literal: true - -require 'rails_helper' - -RSpec.describe 'advanced/advanced_search_form', type: :view do - let(:context) { {} } - - let(:config) { Blacklight::Configuration.new } - - before do - stub_template 'advanced/_advanced_search_fields.html.erb' => 'Advanced Search Fields' - stub_template 'advanced/_advanced_search_facets.html.erb' => 'Advanced Search Facets' - stub_template 'advanced/_advanced_search_submit_btns.html.erb' => 'Advanced Search Submit Buttons' - end - - it 'renders an additional search button at the top of the form' do - render 'advanced/advanced_search_form', advanced_search_context: context, blacklight_config: config - - expect(rendered).to have_selector 'form h1.page-header input#advanced-search-submit-top' - end -end diff --git a/spec/views/browse/authors.html.erb_spec.rb b/spec/views/browse/authors.html.erb_spec.rb index 00ede40e..42224acd 100644 --- a/spec/views/browse/authors.html.erb_spec.rb +++ b/spec/views/browse/authors.html.erb_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'browse/authors', type: :view do +RSpec.describe 'browse/authors' do before do controller.params = { action: 'authors' } assign(:author_list, instance_spy(BrowseList, entries: [])) @@ -10,9 +10,9 @@ end it 'renders an error message when there are no items to show' do - expect(rendered).not_to have_selector 'table' - expect(rendered).to have_selector '.alert-warning h4', - text: 'No authors found. Try the following tips to revise your search:' - expect(rendered).to have_selector 'ol' + expect(rendered).to have_no_css 'table' + expect(rendered).to have_css '.alert-warning h4', + text: 'No authors found. Try the following tips to revise your search:' + expect(rendered).to have_css 'ol' end end diff --git a/spec/views/browse/call_numbers.html.erb_spec.rb b/spec/views/browse/call_numbers.html.erb_spec.rb index 5988527c..6e3ac8a4 100644 --- a/spec/views/browse/call_numbers.html.erb_spec.rb +++ b/spec/views/browse/call_numbers.html.erb_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'browse/call_numbers', type: :view do +RSpec.describe 'browse/call_numbers' do before do assign(:shelf_list, instance_spy(ShelfListPresenter, list: [], classification: classification)) render @@ -12,9 +12,9 @@ let (:classification) { 'lc' } it 'renders an error message when there are no items to show' do - expect(rendered).to have_selector 'h1', text: 'Browse by LC Call Number' - expect(rendered).not_to have_selector 'table' - expect(rendered).to have_selector '.alert-warning h2', text: 'No records found.' + expect(rendered).to have_css 'h1', text: 'Browse by LC Call Number' + expect(rendered).to have_no_css 'table' + expect(rendered).to have_css '.alert-warning h2', text: 'No records found.' end end @@ -22,9 +22,9 @@ let (:classification) { 'dewey' } it 'renders an error message when there are no items to show' do - expect(rendered).to have_selector 'h1', text: 'Browse by DEWEY Call Number' - expect(rendered).not_to have_selector 'table' - expect(rendered).to have_selector '.alert-warning h2', text: 'No records found.' + expect(rendered).to have_css 'h1', text: 'Browse by DEWEY Call Number' + expect(rendered).to have_no_css 'table' + expect(rendered).to have_css '.alert-warning h2', text: 'No records found.' end end end diff --git a/spec/views/browse/subjects.html.erb_spec.rb b/spec/views/browse/subjects.html.erb_spec.rb index f38cc38d..0d90c39d 100644 --- a/spec/views/browse/subjects.html.erb_spec.rb +++ b/spec/views/browse/subjects.html.erb_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'browse/subjects', type: :view do +RSpec.describe 'browse/subjects' do before do controller.params = { action: 'subjects' } assign(:subject_list, instance_spy(BrowseList, entries: [])) @@ -10,9 +10,9 @@ end it 'renders an error message when there are no items to show' do - expect(rendered).not_to have_selector 'table' - expect(rendered).to have_selector '.alert-warning h4', - text: 'No subjects found. Try the following tips to revise your search:' - expect(rendered).to have_selector 'ol' + expect(rendered).to have_no_css 'table' + expect(rendered).to have_css '.alert-warning h4', + text: 'No subjects found. Try the following tips to revise your search:' + expect(rendered).to have_css 'ol' end end diff --git a/spec/views/browse/titles.html.erb_spec.rb b/spec/views/browse/titles.html.erb_spec.rb index aefa4e29..79e960b9 100644 --- a/spec/views/browse/titles.html.erb_spec.rb +++ b/spec/views/browse/titles.html.erb_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'browse/titles', type: :view do +RSpec.describe 'browse/titles' do before do controller.params = { action: 'titles' } assign(:title_list, instance_spy(BrowseList, entries: [])) @@ -10,7 +10,7 @@ end it 'renders an error message when there are no items to show' do - expect(rendered).not_to have_selector 'table' - expect(rendered).to have_selector '.alert-warning h2', text: 'No records found.' + expect(rendered).to have_no_css 'table' + expect(rendered).to have_css '.alert-warning h2', text: 'No records found.' end end diff --git a/spec/views/external_links/_index_external_links.html.erb_spec.rb b/spec/views/external_links/_index_external_links.html.erb_spec.rb index dd9150ee..d7d43704 100644 --- a/spec/views/external_links/_index_external_links.html.erb_spec.rb +++ b/spec/views/external_links/_index_external_links.html.erb_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'external_links/index_external_links', type: :view do +RSpec.describe 'external_links/index_external_links' do context 'when PSU Digital Collectionslinks present' do let(:document) { SolrDocument.new( { @@ -53,8 +53,8 @@ it 'does not renders Online Version links' do render 'external_links/index_external_links', document: document, show_hathi_links: false - expect(rendered).not_to have_link('purl.access.gpo.gov', href: 'http://purl.access.gpo.gov/GPO/LPS73013') - expect(rendered).not_to have_link('purl.access.gpo.gov', href: 'http://purl.access.gpo.gov/GPO/LPS73014') + expect(rendered).to have_no_link('purl.access.gpo.gov', href: 'http://purl.access.gpo.gov/GPO/LPS73013') + expect(rendered).to have_no_link('purl.access.gpo.gov', href: 'http://purl.access.gpo.gov/GPO/LPS73014') expect(rendered).not_to include('Pt.1, text version:') expect(rendered).not_to include('This is a note') expect(rendered).not_to include('Pt.1, PDF version:') @@ -71,7 +71,7 @@ it 'does not renders Related Resources links' do render 'external_links/index_external_links', document: document, show_hathi_links: false - expect(rendered).not_to have_link('related.resource', href: 'http://related.resource') + expect(rendered).to have_no_link('related.resource', href: 'http://related.resource') expect(rendered).not_to include('This is a prefix:') expect(rendered).not_to include('This is a note') end @@ -96,8 +96,8 @@ it 'does not render Hathi links when show_hathi_links is false' do render 'external_links/index_external_links', document: document, show_hathi_links: false - expect(rendered).not_to have_link(href: 'https://catalog.hathitrust.org/api/volumes/oclc/12345.html') - expect(rendered).not_to have_css("img[src*='HathiTrust_logo']") + expect(rendered).to have_no_link(href: 'https://catalog.hathitrust.org/api/volumes/oclc/12345.html') + expect(rendered).to have_no_css("img[src*='HathiTrust_logo']") expect(rendered).not_to include(I18n.t!('blackcat.hathitrust.public_domain_text')) end end diff --git a/spec/views/external_links/_show_external_links.html.erb_spec.rb b/spec/views/external_links/_show_external_links.html.erb_spec.rb index d3f686cf..a5b339ae 100644 --- a/spec/views/external_links/_show_external_links.html.erb_spec.rb +++ b/spec/views/external_links/_show_external_links.html.erb_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'external_links/show_external_links', type: :view do +RSpec.describe 'external_links/show_external_links' do context 'when PSU Digital Collectionslinks present' do let(:document) { SolrDocument.new( { @@ -97,8 +97,8 @@ it 'does not render Hathi links when show_hathi_links is false' do render 'external_links/show_external_links', document: document, show_hathi_links: false - expect(rendered).not_to have_link(href: 'https://catalog.hathitrust.org/api/volumes/oclc/12345.html') - expect(rendered).not_to have_css("img[src*='HathiTrust_logo']") + expect(rendered).to have_no_link(href: 'https://catalog.hathitrust.org/api/volumes/oclc/12345.html') + expect(rendered).to have_no_css("img[src*='HathiTrust_logo']") expect(rendered).not_to include(I18n.t!('blackcat.hathitrust.public_domain_text')) end end diff --git a/spec/views/shared/_header_navbar.html.erb_spec.rb b/spec/views/shared/_header_navbar.html.erb_spec.rb index b0c83171..deb81b76 100644 --- a/spec/views/shared/_header_navbar.html.erb_spec.rb +++ b/spec/views/shared/_header_navbar.html.erb_spec.rb @@ -2,7 +2,7 @@ require 'rails_helper' -RSpec.describe 'shared/_header_navbar', type: :view do +RSpec.describe 'shared/_header_navbar' do let(:blacklight_config) { Blacklight::Configuration.new } before do @@ -13,12 +13,12 @@ xit 'displays search bar except on Advanced Search' do render 'shared/header_navbar' - expect(rendered).to have_selector '.navbar-search' + expect(rendered).to have_css '.navbar-search' end xit 'does not display search bar on Advanced Search' do assign(:search_fields_for_advanced_search, :search_bar) render 'shared/header_navbar' - expect(rendered).not_to have_selector '.navbar-search' + expect(rendered).to have_no_css '.navbar-search' end end